Hypothetical Hecl
I did some 'playing' with Hecl the other day, to see what it might look like if implemented in a slightly different way, and I thought I'd share what I was thinking about. Keep in mind that
I haven't thought this through completely:-)
It's not something I'm going to just rush out and do in the near future. It's definitely a Hecl 2.0 sort of idea.
My notion was to make use of the ClassCommand feature to have at least simple types be hooked directly to the relevant Java types, and dealt with through methods, rather than commands. For instance:
$i + 10
instead of
+ $i 10
Where $i is, in the first case, a Java Integer, rather than a Hecl type.
What it would be doing internally is something like this:
$i is recognized as the object to act on.
It's an Integer, so the corresponding ClassCommand is looked up and executed with + and 10 as arguments.
The classcommand for Integer has a + method that accepts an argument, in this case, 10, which is added to the value of $i, and returned as a new Integer.
Without a "real" (where real also means bloated, memory and space hungry) parser, Hecl is never going to have a C-like syntax - you still wouldn't be able to do foo = 1 + 2 + 3 - but this just might make a significant amount of people more comfortable with Hecl, which would be a good thing. You could do something like this:
set i 1
while { $i < 1000000 } {
set i [$i + 1]
}
instead of
set i 1
while { < $i 1000000 } {
set i [+ $i 1]
}
I actually built a really simple HeclInteger class that implements <
and + as methods to Integer ObjectThings, in order to test out this idea, and it seems to run about as fast as the regular Hecl version.
I welcome any thoughts or comments on the idea.
Syndicated 2008-05-04 08:54:00 (Updated 2008-05-04 09:02:28) from David's Computer Stuff Journal
FOAF updates: Trust rankings are now exported, making the data available to other users and websites. An external FOAF URI has been added, allowing users to link to an additional FOAF file.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!