Re: my $pi is constant = 3;

2005-08-18 Thread Autrijus Tang
On Fri, Aug 19, 2005 at 01:36:30AM +0800, Autrijus Tang wrote: > BEGIN { > &foo := a Sub is stub { > ($a) := &?Internals::GETARGS(); > $a = 1 unless exists $a; > # real body begins here > ... > }; > } Er, sorry, the ($a) would need a my()

Re: my $pi is constant = 3;

2005-08-18 Thread Larry Wall
On Fri, Aug 19, 2005 at 01:36:30AM +0800, Autrijus Tang wrote: : On Thu, Aug 18, 2005 at 10:26:00AM -0700, Larry Wall wrote: : > Sure. Though it probably also wants to stay as metadata associated : > with the signature, since part of the reason for putting it in : > the signature in the first plac

Re: my $pi is constant = 3;

2005-08-18 Thread Autrijus Tang
On Thu, Aug 18, 2005 at 10:26:00AM -0700, Larry Wall wrote: > Sure. Though it probably also wants to stay as metadata associated > with the signature, since part of the reason for putting it in > the signature in the first place is so that optimizers can install > constants on the caller end, at l

Re: my $pi is constant = 3;

2005-08-18 Thread Larry Wall
On Fri, Aug 19, 2005 at 01:17:51AM +0800, Autrijus Tang wrote: : Also, preemptively -- I think the corresponding "delete $a" is insane, : as it would just lift up the constancy problem one level, defeating the : no rebinding restriction. I think in general the only time you're allowed to monkey wi

Re: my $pi is constant = 3;

2005-08-18 Thread Larry Wall
On Fri, Aug 19, 2005 at 01:15:23AM +0800, Autrijus Tang wrote: : On Thu, Aug 18, 2005 at 10:09:16AM -0700, Larry Wall wrote: : > In other words, you could desugar : > : > sub foo ($a = 1) {...} : > : > to : > : > sub foo ($a) { : > $a = 1 unless exists $a; : > ... : > } : :

Re: my $pi is constant = 3;

2005-08-18 Thread Autrijus Tang
On Fri, Aug 19, 2005 at 01:15:23AM +0800, Autrijus Tang wrote: > On Thu, Aug 18, 2005 at 10:09:16AM -0700, Larry Wall wrote: > > In other words, you could desugar > > > > sub foo ($a = 1) {...} > > > > to > > > > sub foo ($a) { > > $a = 1 unless exists $a; > > ... > > } > >

Re: my $pi is constant = 3;

2005-08-18 Thread Autrijus Tang
On Thu, Aug 18, 2005 at 10:09:16AM -0700, Larry Wall wrote: > In other words, you could desugar > > sub foo ($a = 1) {...} > > to > > sub foo ($a) { > $a = 1 unless exists $a; > ... > } I like this. Can we go for it, at least for this week? :) Thanks, /Autrijus/ pgpj

Re: my $pi is constant = 3;

2005-08-18 Thread Larry Wall
On Wed, Aug 17, 2005 at 05:31:12PM +, [EMAIL PROTECTED] wrote: : Not only that, but what if what I want is a named constnat undef value? If we went with "bind once" rather than "write once" semantics then after my $foo is readonly := undef; $foo could not be rebound, but saying my $

Re: my $pi is constant = 3;

2005-08-18 Thread mark . a . biggar
-- Mark Biggar [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]> On Wed, Aug 17, 2005 at 08:47:18AM -0700, Larry Wall wrote: > > : >That could be made to work by defining constant to mean you can assign > > : >to it if it's undefined. But then it gets a little harder to reason > > : >about

Re: my $pi is constant = 3;

2005-08-18 Thread Adam Kennedy
Larry Wall wrote: > On Wed, Aug 17, 2005 at 01:56:35PM +1000, Adam Kennedy wrote: > : > : >: If not a special form, should this work? > : >: > : >: my $pi is constant; > : >: $pi = 3; > : > > : >That could be made to work by defining constant to mean you can assign > : >to it if it's und

Re: my $pi is constant = 3;

2005-08-17 Thread Larry Wall
On Wed, Aug 17, 2005 at 09:37:08PM +, Luke Palmer wrote: : On 8/17/05, Larry Wall <[EMAIL PROTECTED]> wrote: : > You could still reason about it if you can determine what the initial : > value is going to be. But certainly that's not a guarantee, which : > is one of the reasons we're now calli

Re: my $pi is constant = 3;

2005-08-17 Thread Luke Palmer
On 8/17/05, Larry Wall <[EMAIL PROTECTED]> wrote: > You could still reason about it if you can determine what the initial > value is going to be. But certainly that's not a guarantee, which > is one of the reasons we're now calling this write/bind-once behavior > "readonly" and moving true constan

Re: my $pi is constant = 3;

2005-08-17 Thread Larry Wall
On Thu, Aug 18, 2005 at 12:02:53AM +0800, Autrijus Tang wrote: : On Wed, Aug 17, 2005 at 08:47:18AM -0700, Larry Wall wrote: : > : >That could be made to work by defining constant to mean you can assign : > : >to it if it's undefined. But then it gets a little harder to reason : > : >about it if $

Re: my $pi is constant = 3;

2005-08-17 Thread Autrijus Tang
On Wed, Aug 17, 2005 at 08:47:18AM -0700, Larry Wall wrote: > : >That could be made to work by defining constant to mean you can assign > : >to it if it's undefined. But then it gets a little harder to reason > : >about it if $pi can later become undefined. I suppose we could > : >disallow undefi

Re: my $pi is constant = 3;

2005-08-17 Thread Larry Wall
On Wed, Aug 17, 2005 at 01:56:35PM +1000, Adam Kennedy wrote: : : >: If not a special form, should this work? : >: : >: my $pi is constant; : >: $pi = 3; : > : >That could be made to work by defining constant to mean you can assign : >to it if it's undefined. But then it gets a little h

Re: my $pi is constant = 3;

2005-08-17 Thread Adam Kennedy
: If not a special form, should this work? : : my $pi is constant; : $pi = 3; That could be made to work by defining constant to mean you can assign to it if it's undefined. But then it gets a little harder to reason about it if $pi can later become undefined. I suppose we could dis

Re: my $pi is constant = 3;

2005-08-12 Thread Larry Wall
as a subtype. : my macro pi { 3 }; : my &pi = { 4 }; Those both live in the function namespace, as would the new constant declarator if we include the sigilless form above . : The form : : my $pi is constant = 3; : : to me bears the disadvantage, that it doesn't look li

Re: my $pi is constant = 3;

2005-08-12 Thread Larry Wall
On Thu, Aug 11, 2005 at 09:52:18PM -0700, Ashley Winters wrote: : On 8/11/05, Larry Wall <[EMAIL PROTECTED]> wrote: : > So either we have to bifurcate the concept into "temporarily constant" : > and "permanently constant", or we force people to distinguish with ::= : > (or "is constant('foo')"), or

Re: my $pi is constant = 3;

2005-08-12 Thread TSa
doesn't hurt my macro pi { 3 }; my &pi = { 3 }; BTW, are all these competing for the same name slot or can some or all exist in parallel? Can they if the type is the same but not for my ::pi ::= 1; my enum ; my macro pi { 3 }; my &pi = { 4 }; The form

Re: my $pi is constant = 3;

2005-08-11 Thread Ashley Winters
On 8/11/05, Larry Wall <[EMAIL PROTECTED]> wrote: > So either we have to bifurcate the concept into "temporarily constant" > and "permanently constant", or we force people to distinguish with ::= > (or "is constant('foo')"), or we make some representations about the > requirement for the compiler t

Re: my $pi is constant = 3;

2005-08-11 Thread Larry Wall
On Fri, Aug 12, 2005 at 01:43:43AM +0800, Autrijus Tang wrote: : On Wed, Aug 10, 2005 at 12:41:17PM -0700, Larry Wall wrote: : > : If yes, what does it desugar to? : > : : > : my $pi is constant := 3; : > : my $pi is constant ::= 3; : > : > In this case it desugars to :

Re: my $pi is constant = 3;

2005-08-11 Thread Autrijus Tang
On Wed, Aug 10, 2005 at 12:41:17PM -0700, Larry Wall wrote: > : If yes, what does it desugar to? > : > : my $pi is constant := 3; > : my $pi is constant ::= 3; > > In this case it desugars to > > my $pi is constant = 3; > > :-) However, I wonder if th

Re: my $pi is constant = 3;

2005-08-10 Thread Larry Wall
On Wed, Aug 10, 2005 at 11:48:16PM +0200, TSa wrote: : Only that ?$b is not marked is constant? Strange that is. Straight out of the apocalypse--parameters default to constant. Larry

Re: my $pi is constant = 3;

2005-08-10 Thread TSa
HaloO, Larry Wall wrote: In this case it desugars to my $pi is constant = 3; :-) In other words the assignment to a my turns into an ordinary assignment that happens at runtime. Hopefully, since $pi is marked constant, it could be optimized to a binding in many cases, but that's no

Re: my $pi is constant = 3;

2005-08-10 Thread Larry Wall
On Thu, Aug 11, 2005 at 02:22:04AM +0800, Autrijus Tang wrote: : According to S06: : : my $pi is constant = 3; Perhaps the actual rewrite is my $pi is constant({ 3 }); much like state $where = $California; is desugared to state $where is first({$California}); or some such

Re: my $pi is constant = 3;

2005-08-10 Thread Larry Wall
On Thu, Aug 11, 2005 at 02:22:04AM +0800, Autrijus Tang wrote: : According to S06: : : my $pi is constant = 3; : : Is this a special form? I believe any assignment to a declarator is potentially a special form, or we can't get assignment to "has" and "state" to wo

my $pi is constant = 3;

2005-08-10 Thread Autrijus Tang
According to S06: my $pi is constant = 3; Is this a special form? If yes, what does it desugar to? my $pi is constant := 3; my $pi is constant ::= 3; If not a special form, should this work? my $pi is constant; $pi = 3; If yes, should this pass compilation? my $pi