Re: adverbs o operators
Larry Wall larry-at-wall.org |Perl 6| wrote: As for marking each op individually, it might be possible if we add a whitespace dependency between lt:lc and lt :lc, but 1 ..:by(2) 100 is pretty ugly. Larry So do they have to go at the end of the whole expression in the current grammar? I don't follow about the spaces. Do you write $a lt:lc $b le:lc $c or $a lt :lc $b le :lc $c or $a lt $b :lc le $c :lc ? Making the default a contextual variable would allow the library to do it with no core syntax concerns: $+Str::compare = 'lc'; # applies to rest of lexical scope if $a lt $b le $c ... --John
Re: adverbs o operators
HaloO, John M. Dlugosz wrote: So do they have to go at the end of the whole expression in the current grammar? I don't follow about the spaces. The problem is term versus operator parsing. Do you write $a lt:lc $b le:lc $c I think that works and looks best. My favorite hope is that $x = log:2 $y; flies, as well. $x = log:base(2) $y; is a bit lengthy and $x = log $y, :base(2); looks more like a two element list assigned to $x. or $a lt :lc $b le :lc $c That is a parse error two terms in a row. or $a lt $b :lc le $c :lc No problem here. Regards, TSa. -- The unavoidable price of reliability is simplicity -- C.A.R. Hoare Simplicity does not precede complexity, but follows it. -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Re: adverbs o operators
On Thu, Aug 07, 2008 at 06:15:07PM +0200, TSa wrote: Do you write $a lt:lc $b le:lc $c I think that works and looks best. My favorite hope is that $x = log:2 $y; flies, as well. $x = log:base(2) $y; is a bit lengthy and $x = log $y, :base(2); looks more like a two element list assigned to $x. That's because it *is* a two element list. In the current scheme of things, you have to put: $x = log $y :base(2); The point being that adverbs are recognized only where an infix is expected. Otherwise they're just pairs used as nouns. Currently after log a term is expected, so log:base(2) would be parsed as log(:base(2)). The whitespace proposal is essentially to require whitespace between any operator any following pair if the pair is intended to be a noun and not an adverb. We actually thought of this years ago in the design meeting and rejected it at the time because, in particular 123,:foo would surprise a lot of people by looking for the ,:foo operator. But maybe we could put in an exception for confusing forms that are guaranteed not to work. I can't imagine why anyone would want a ,:foo operator, for instance. Doubtless there are other confusing operators though. Alternately, we could force everyone to put space after comma. :) Larry
Re: adverbs o operators
HaloO, Larry Wall wrote: The whitespace proposal is essentially to require whitespace between any operator any following pair if the pair is intended to be a noun and not an adverb. So, then my log:base(2) would still look for the positional argument, right? Alternately, we could force everyone to put space after comma. :) Wouldn't it suffice to enforce to disambiguate ',:' as ', :'? Regards, TSa. -- The unavoidable price of reliability is simplicity -- C.A.R. Hoare Simplicity does not precede complexity, but follows it. -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan