1. Re: What's Holding Euphoria Back
- Posted by Scott Murray <FaIkon1313 at AOL.COM> Feb 04, 1999
- 421 views
-- David Cuny >Obviously, there is no trivial fix for this. I had investigated putting >together a pre-processor for structures some time back, but dropped it when >it became apparent that because of their recursive nature, it would be >impossible to resolve structures until run time. Regarding namespace, that's right. But I've been playing with parsing and translation, in hopes of creating a multiline macro preprocessor that would allow people to create their own language constructs...structures, class declarations, block comments, etc. And, sure enough, I found a simple way of translating pseudocode structure definitions into true Euphoria syntax: struct car string make string model atom miles object owner end struct translates to: constant make = 1, model = 2, miles = 3, owner = 4 type car( object v ) if sequence( v ) then if length( v ) = 4 then if string( v[make] ) then if string( v[model] ) then if atom( v[miles] ) then return( TRUE ) end if --miles end if --model end if --make end if --structure size end if --sequence return( FALSE ) end type The same pattern works for all complex structures I can think of, assuming the types of the elements have been predefined (string in this case). It's repetitive and ugly to type out by hand, but easy with a simple translator. And usage is normal, as they are Euphorian sequences. Since they translate to Euphorian type-declarations, they can be elements of each other, and themselves. struct squad car squadcar object troops end struct car Acar Acar[make] = Ford Acar[model] = Mustang squad SquadA SquadA[squadcar] = Acar But, as you said, it's not really a trivial task.