Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ethan (3163)

  reversethis-{ed. ... rap.nov.olissat}

Being a 25-year old chap living in the western-most town of Germany. Stuying communication and information science and being a huge fan of XS-related things.

Journal of ethan (3163)

Thursday August 14, 2003
03:24 AM

in the language twilight

[ #14114 ]

It turns out that String::Ruby (see last journal entry) turns out to be harder than expected. The problem is that duplicating Ruby's behaviour will yield something that is definitely not what perl does. For instance the autoincrement on strings. Ruby will do it like this:

                print "!!99!!".next ==> !!100!!
                print "!!ZZ!!".next ==> !!AAA!!

So first I have to think whether that would make sense in Perl, too. And if so, I'd have to implement it which is a fickle work when doing it in C.

Another example is "-0xAA".hex. In Ruby this will result in -170. Perl's numeric.c:Perl_grok_hex doesn't know how to handle the minus so it spits out 0. At least making this behave as in Ruby is easy in XS.

The hex-thing is also a good example that Ruby does in fact do a few things better than Perl. There is no reason why numbers in hexadecimal notation shouldn't be allowed to have a minus prefixed.

A serious problem is "string".intern. In Ruby this returns the symbol corresponding to "string". A Ruby symbol appears to be something that bears some ressemblance to a Perl typeglob (but I might be completely wrong on this) so in String::Ruby I simply return a reference to the symbol-table of the given name. I am quite aware that this does not really make sense in the world of Perl.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.