Re: Eu vs perl
- Posted by David Cuny <dcuny at LANSET.COM> Dec 08, 1999
- 559 views
Everett Williams wrote: > The problem with programmer added prefixes is that they > are static and do not allow for multiple occurrences. If I have > a structure that describes a file, I may have three files with > the same structure open at the same time. I've used two different ways to deal with this. I can create a 'generic' sequence to hold everything: sequence the the = {} The data structure describing objects: constant Name = 1, SSN = 2 And a routine to create new objects: function newItem() the = append( the, repeat( 0, 100 ) return length( the ) end function Here's a generic 'set' and 'get' function: procedure Set( integer self, integer attribute, object value ) the[self][attribute] = value end procedure function Get( integer self, integer attribute ) return the[self][attribute] end procedure I can then create new objects: constant Fred = newItem() constant Joe = newItem() and assign and modify them: Set( Fred, Name, "Fred" ) Set( Fred, SSN, "000-00-0000" ) Set( Joe, Name, "Joe" ) Set( Joe, SSN, "111-11-1111" ) Which is the same as: the[Fred][Name] = "Fred" the[Fred][SSN] = "000-00-0000" the[Joe][Name] = "Joe" the[Joe][SSN] = "111-11-1111" Not entirely elegant, but it gets the job done. That's the approach Llama took. The double indexing is expensive, and using Get/Set makes it more so. Llama was rightly criticized as having a lot of overhead in the data structures. In my new toolkit, I take a slightly different approach: sequence name, ssn name = {} ssn = {} function newItem() name = append( name, "" ) ssn = append( ssn, "" ) return length( name ) end function Working with objects is now: constant Fred = newItem() constant Joe = newItem() name[Fred] = "Fred" ssn[Fred] = "000-00-0000" name[Joe] = "Joe" ssn[Joe] = "111-11-1111" > Constants are not necessary in a "minimalist" > language. I don't share this dislike of constants. Writing: the[SSN] makes a lot more sense than: the[3] > And I shouldn't accuse. I share some of Jiri's irritation with > the "way" that the libs you have written are headed ... I assume by 'the "way"', you are referring to GUI applications, as opposed to DOS applications. Jiri's complaints seem to be less that I'm writing GUI code, and more that a "DOS" forum is constantly polluted with Windows code. > but I also recognize that this language would be sitting > virtually unused if it wasn't for that very work. Looking at the huge number of DOS contributions on the Euphoria web page, I'd have to disagree. > I'm not quite as irritable as Jiri, but after the third demand > for code I got a little crotchety. But I don't think it's an unreasonable demand. If you can't show me an example of code that demonstrates your claim, then it's difficult for me to believe there's an issue. > but I have not seen much generic string > handling done in your programs... I'm not sure what you mean by 'generic string handling'. I've posted several programs with fairly complex parsers. eBasic converts QBasic code into Euphoria using an LL(1) grammar. PP is a pre-processor for Euphoria that 'enhances' the language with a number of interesting constructs. Eu parses and executes Euphoria code. On a smaller scale, Fix functions much the same as Euphoria's Shroud routine, but correctly handles routine_id, and Res creates resource files by parsing source files. I've posted a couple generic pattern matching routines as well. -- David Cuny