Re: Eu improvements (part 4)
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>
>
> -=ck
> "Programming in a state of Euphoria."
> <a
> href="http://www.cklester.com/euphoria/">http://www.cklester.com/euphoria/</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:
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()?
mycars.addItem("Porche")
myPhones.addItem("123-456-7890");
myGirlFriends.addItem("Jennifer Aniston")
-- no reason for another way to add items
-- get the index
mycars.add("Porche")
idx = mycars.getItemIdx("Porche")
-- again, other ways are not needed or desireable
end procedure
A remarkable increase in brevity and clarity (and faster).
KtB
|
Not Categorized, Please Help
|
|