From: Mathieu Bouchard Date: 2005-01-06T22:54:33+09:00 Subject: Re: Allowing custom number literal suffixes? On Wed, 5 Jan 2005, Brent Roman wrote: > I already define Time(string), so T(string) would really be no great > improvement. It's three less letters, and five less chars if you drop the parens by using just doublequotes. I don't think it's no great improvement, especially considering it's just two chars away from the shortest possible syntax. > It would be neat if we could add some elegant way to represent generic > literal objects. I think backslash is currently undefined outside of > quoted strings. Can someone more familar with the parser confirm > this? Well, I think the backslash character should be reserved for more special needs. > Further, Prefixes and Suffixes need not be single letters: > \-122.12'40"\Long > \+37.19'59"\Lat > call Kernel::Literal::Suffix:Long ('-122.12\'40"') > and Kernel::Literal::Suffix::Lat ('+37.19\'59"') > respectively I think that special-purpose literals aren't used that often, and if they are, it's because there's not enough "separation between code and data" (i'm thinking of data-driven programming...). Else, in the case I need them shortcuts for short scripts and IRB, I'd rather use global methods. For those with (possibly irrational) fear of global methods, there's the possibility of making them into a Module to be included in whichever context in which the shortcuts are desired. Else we may as well turn all parse-errors into retriable/resumable exceptions, and then all "SIN TAX" problems would be solved once and for all. ;-) _____________________________________________________________________ Mathieu Bouchard -=- Montr�al QC Canada -=- http://artengine.ca/matju