Re: Eu improvements (part 4)
- Posted by c.k.lester <euphoric at cklester.com> Jan 05, 2007
- 665 views
Karl Bochert wrote: > cklester wrote: > > Karl Bochert wrote: > > > . The function add() really should do what it says - add a word to the > > > list. > > Then you'd want something like this: > > <a > > href="http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=6&fromYear=B&toMonth=8&toYear=B&postedBy=cklester&keywords=Updating+parameters+in+a+procedure+%2F+function">http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=6&fromYear=B&toMonth=8&toYear=B&postedBy=cklester&keywords=Updating+parameters+in+a+procedure+%2F+function</a> > A very nicely presented workaround for the lack of PBR. > Whats remarkable is the hoops you must jump through. > Your example using this version of PBR: > }}} <eucode> > function list.addItem(object item) > append(list, item) > end function > function list.getItemIdx(object item) > -- PBR not needed for this fct, but what the heck > return find(item, list) > end function > > procedure main() > sequence myCars, myPhones, myGirlFriends > atom idx > myCars = {} myPhones = {} myGirlFriends = {} > --? do I need these inits? why? how do I put them in addItem()? It would work a little differently for OOP. You'd need something like the following: myCars = newObject("myCars") -- myCars previously defined as a holder of car records -- this is just an index to the internal list of objects auto = newObject("automobile") -- automobile previously defined as a record of car data -- this is just an index to the internal list of objects property(auto,"maker","Ford") -- then to add the automobile to the myCars list/db: addObject(myCars,auto) -- or somesuch This is possible without any change to Euphoria right now. I bet some current incarnation of a Euphoria OOP library does this exact thing. Dot notation will be syntactic sugar, right? Not that there's anything wrong with that. :)