This is another great example of why I love this list. :o] I live in GA, so far out in the boonies that I can't get cable or broadband at *all* except for by satellite. I've stopped trying to explain what I do, because I start saying things like this, and they glaze and visibly regret it, lol....
Now I just tell them my official job title is "computer monkey". That works pretty well. :) But so that this post isn't (hopefully) entirely hot air, How does this sort of adverbial typecasting relate back to compile time typing? The old my Dog $spot thing? There seems to be a significant relationship, but I can't wrap my head around where the underlying mechanics might be usefully applied. <goes off to reread the synopses/exegeses et alii> --- Ryan Richter <[EMAIL PROTECTED]> wrote: > On Tue, Dec 04, 2007 at 07:39:16AM -0800, Larry Wall wrote: > > On Sun, Oct 07, 2007 at 03:01:06PM -0600, David Green wrote: > > > What happened to the suggestion of using ` to designate units? > > > > It's kinda caught between two other notions. On the one hand, > > we're trying to reserve ` for user definition, in part because it's > > so difficult to tell from ' in many fonts so we're avoiding it for > > standard usage. On the other hand, it's not clear that units > aren't > > generally just simple multiplication by a scaling factor: 1*in, > where > > 1*in == 2.54*cm, for instance. Units could also be viewed as type > > conversion, which would give us kg(1) and 1.kg as conversion forms > > in current Perl 6. Since 1.kg is essentially using the units as a > > postfix, presumably the 1kg form could also work on literals, just > as > > we currently allow 1i to convert 1 to i via the postfix:<i> > operator. > > (And I suppose there's a sense in which 10e-2 is specifying the > > scaling factor of the left side explicitly.) > > > > In any case, though, if we treated them as type names rather than > > just methods, we'd probably want to require predeclaration of unit > > names since a type name like "kg" or "in" or "fortnight" could > easily > > collide with a user-defined routine. Or maybe they still want some > > special sigil-ish mark to stay in their own namespace. Dunno. I > don't > > think we have to solve that for 6.0.0 in any case, especially if we > > require predeclaration of which unit names are wanted, in which > case > > there might just be a units pragma that can pull in selections of > > the predefined units: > > > > use units :cgs, :nasa, <μfortnight gibibyte>; > > my newton $thrust = 42.lbf; > > > > But with a sigilish mark we could just pull in all the units from > > /usr/share/units.dat, I suppose. > > I don't know if I ever mentioned it on the mailing list, but a while > back I did some work on a units module that uses units.dat > (examples/rules/unitsdat-grammar.pm in the pugs repo). I think > that a simple postfix syntax (e.g.) doesn't give you the ability to > specify the kind of composite units that are common in scientific > applications where units are heavily used (e.g. Gauss per square root > Hertz). Those kind of units also rule out simple type-based units, > e.g. > having roles for length, mass, etc. - you can't do a role to the -7/3 > power. I settled on a syntax that allows a mini-language similar to > units(1): > > 9.8.:as<m / s ** 2> > $field_noise.:as<gauss / sqrt(Hz)> > > But someone may be able to come up with something better. My > implementation does unit type-checking at runtime, but compile-time > checking would be much nicer where possible. It would also be cool > to > be able to define roles that can represent themselves in several > different units: > > role Photon does NumUnit { ??? } > my Photon $p .=new( energy => 42.:as<eV> ); > say "energy is $p.:as<zJ> zeptojoules"; > say "wavelength is $p.:as<angstrom> â«"; > say "frequency is $p.:as<THz> THz"; > > -ryan > ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs