From: "Ara.T.Howard" Date: 2005-10-25T07:32:01+09:00 Subject: Re: A comparison by example of keyword argument styles On Tue, 25 Oct 2005, Trans wrote: > Ara.T.Howard wrote: > >> i think you cannot ever have both trailing optional arguments AND keywords >> with current ruby calling conventions since it will always be impossible to >> determine whether the last hash is a value for an optional argument or the >> set of keywords. the only way is to have a syntax that calls methods with >> keywords that are not an inlines hash, eg >> >> foo 42, keyword : 42.0 # optional gets default value >> foo 42, keyword => 42.0 # optional IS a hash , keyword is not given > > Ah, at first I was gogin to say "STOP! You've got this all distorted. These > are parameters, not hash keys. Related but different. So why are you using > strings? It's this: > > foo 42, keyword => 40 + 2 > > There is no ambiguity." > > But now I see you get to this To which I say: Exactly. This is how it ought > to be -- IF done this way. Matz implementation actually is NOT like this > though and has worse problems some of which you describe above. it's slippery all right. >> when i was coding parseargs all this became apparent very quickly. trying >> to write a parser for any proposed syntax is a good exercise that shows how >> nice a real keyword syntax might make things. > > What do you mean by real? i mean something other that collected trailing hash keys. mind you, i'm happy with the current situation. but if syntax support would be added to ruby it's a slippery slope when you through optional arguments, and trailing open hashes into the mix. regards. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | anything that contradicts experience and logic should be abandoned. | -- h.h. the 14th dalai lama ===============================================================================