Re: Hoping that Params::Validate is not needed in Perl6

2005-08-18 Thread Yuval Kogman
On Wed, Aug 17, 2005 at 23:43:43 -0500, Dave Rolsky wrote:

 But I'd really like to get this stuff done at compile time wherever possible. 
  
 If I write this:
 
validate( credit_card_number: $number );
 
 it should blow up at compile time, right?

So should MMD: The type signatures are rigid, and the moment things
get closed (no more MMD alternatives are possible), if your
dispatches don't have any MMD candiates it's just as much a type
error as a normal sub with a bad type.

-- 
 ()  Yuval Kogman [EMAIL PROTECTED] 0xEBD27418  perl hacker 
 /\  kung foo master: *shu*rik*en*sh*u*rik*en*s*hur*i*ke*n*: neeyah



pgpT33LKABXOy.pgp
Description: PGP signature


Re: Time::Local

2005-08-18 Thread Braňo Tichý

Well, right now one of the great things about looking at the wall to
read the clock and see the time, is that you know that based on the time
of day and the time of year, and where you are, roughly how far through
the actual solar day it is.  It's crude, but useful.  Just ask a Dairy
Farmer.



Does the Dairy Farmer need time with seconds precision?
Would he know his longitude and how to make correction to the time?
(If he is a person, wouldn't it be easier for him just to buy GPS?)


Of course feel free to consider this all worthless heckling, given the
lack of time I've been putting towards an implementation of all this ;).

Sam.



Same here.

Maybe this lengthy discussion isn't really that useful. I think it's about 
defaults, but Perl6 will have packages -- so everyone not content with the 
default handling of time will be able to override it. Or maybe there could 
be a pragma (`no leapseconds`?). Or maybe there could be a package on CP6AN 
named Time::Leapseconds::Data.


Related question: is it possible to specify validity of a package? Something 
along the lines this package starts to be deprecated/imprecise/outdated 
after 2007.


braňo tichý



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 it if $pi can later become undefined.  I suppose we could
  : disallow undefine($pi) though.
 
 If you can assign it when it contains an undefined value, bad
 things happen:
 
 sub f ($x is readonly) { $x = 10 }
 my $a; f($a);
 
 Compare this with:
 
 my $x is readonly;
 $x = 10;
 
 If it is defined as bound to a immutable value cell, both cases
 above would fail, which is imho the easiest to explain.


Not only that, but what if what I want is a named constnat undef value?


 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 undefine($pi) though.
 
 If you can assign it when it contains an undefined value, bad
 things happen:
 
 sub f ($x is readonly) { $x = 10 }
 my $a; f($a);
 
 Compare this with:
 
 my $x is readonly;
 $x = 10;
 
 If it is defined as bound to a immutable value cell, both cases
 above would fail, which is imho the easiest to explain.
 
  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 constants to a separate declarator:
  
  my $pi is readonly;
  $pi = 3;
 
 The question remains, whether you can bind the readonliness away:
 
 my $pi is readonly; # undef at this point
 my $e is rw = 2.7;
 $pi := $e;
 $pi = 9;
 
 I can argue both sides -- rebindable is easier to implement, but
 non-rebindable is perhaps more intuitive.
 
 Thanks,
 /Autrijus/
 


RE: Ambiguity of parsing numbers with underscores/methods

2005-08-18 Thread Gordon Henriksen
Larry Wall wrote:

 Yes, that's a convenient escape.  But really, arguments from principle
 aside, the underlying question is what someone will see if they look
 at 1.e5, and I suspect most people will see a number with an exponent.
 This is a spot where Ruby violates Least Surprise, at least for people
 who aren't used to seeing methods hanging off of literals.

To the original point, I have to seriously question the usefulness of
invoking ambiguously named methods on numeric literals...

1e5  # number
1.0e5# number
(1).e5   # method call, since you really mean it

The decimal point without a fractional part looks bizarre to me:

1.e5 # syntax error

Surely +. and -. are invalid syntax?  (\.\d+)? , not  (\.\d*)? .

-- 
 
Gordon Henriksen
[EMAIL PROTECTED]



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 undefined.  But then it gets a little harder to reason
 : about it if $pi can later become undefined.  I suppose we could
 : disallow undefine($pi) though.
 : 
 : Which would basically throw away compile-time optimizations relating to 
 : constants wouldn't it?
 
 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 constants to a separate declarator:
 
 my $pi is readonly;
 $pi = 3;
 
 vs
 
 constant $pi = 3;
 
 or
 
 constant Num pi = 3;
 
 or if you like, even
 
 constant π = 3;
 
 Larry

OK, so then there is not is constant at all... just is readonly?
Makes a lot more sense to me.

Adam


Re: Time::Local

2005-08-18 Thread Dan Kogai

On Aug 17, 2005, at 00:29 , Larry Wall wrote:

which gives us these possibilities.
大務big / (perform) duty


Perl6 to people here.


太夢fat, big / dream


Perl6 for the rest of us.


対夢oppose, against, pair / dream


Pugs?


待夢wait / dream


Perl6 to Oreilly ?


滞夢stop, stagnate / dream


Perl6 to kansai.pm :)

All sounds pretty perl6 to me.

Oh, be careful of this one.


台無stand, platform / not, none, cease to be


Usually this one reads 'Dai-Nashi' (kun-yomi), meaning to blow from  
grounds up.


Dan the Man from a Place with Too Many Puns and Funs



Re: Serializing code

2005-08-18 Thread Ingo Blechschmidt
Hi, 
 
Yuval Kogman nothingmuch at woobling.org writes: 
 So now that the skeptics can see why this is important, on the 
 design side I'd like to ask for ideas on how the code serialization 
 looks... 
  
  sub { $?DOM.document.write(phello world!/p) }.emit( 
   :runtime($browser_autodetect_object), 
   # this can be guessed by asking the $runtime object: 
   # :languagejavascript, 
  ); 
  
 This is superficially nice, 
 
Indeed! 
 
 but here's what's missing: 
[...] 
 
  - what exactly is a code object? 
   - a wrapper for some PIL code 
   - that can be executed by the runtime 
 
Code objects may as well be executed at compile-time 
(think macros, use and BEGIN blocks), but...: 
 
sub foo { $?DOM.document.write(...) } 
BEGIN { foo() };   # error, there's no $?DOM object 
   # at compile-time! 
 
  - what exactly is code.emit 
   - also an object? 
 
Well, you call code.emit above, so it's probably a Code 
object, even though it calls subs and methods from the 
Perl6::Internals namespace (or somesuch). 
 
  - handling of data 
   - types of: 
- globals? 
 
I've probably misunderstood you, but can't globals, like all 
other variables, have any type you want them to have? 
 
- closures? 
 
A subclass of Code, e.g. Bare. 
 
   - two examples of data sharing policies: 
- the border between the webapp and the browser is 
  smudged by serialization and proxy objects 
- the border between the webapp and the browser is 
clear 
  and distinct, and calls between the two are done by 
  explicitly invoking one runtime from the other 
 
I'd like to have a pragma to switch between these policies. 
 
 
--Ingo 



Re: Hoping that Params::Validate is not needed in Perl6

2005-08-18 Thread Larry Wall
On Thu, Aug 18, 2005 at 11:03:22AM -0500, Dave Rolsky wrote:
: Hurry up and finish.  I want to use this language, darnit!  And yes, I 
: know about pugs, obviously, but for production usage I need less of a 
: moving target ;)

Yes, Perl 6 is a moving target--but one of the most bothersome facts
of life is that, to get anywhere you're not, you have to move...

Larry


Re: Hoping that Params::Validate is not needed in Perl6

2005-08-18 Thread chromatic
On Wed, 2005-08-17 at 23:43 -0500, Dave Rolsky wrote:

 But I'd really like to get this stuff done at compile time wherever 
 possible.  If I write this:
 
validate( credit_card_number: $number );
 
 it should blow up at compile time, right?

Does that depend on how closed you want Perl 6 to think your world is at
compile time?

-- c



Re: Hoping that Params::Validate is not needed in Perl6

2005-08-18 Thread Autrijus Tang
On Thu, Aug 18, 2005 at 10:02:23AM -0700, chromatic wrote:
 On Wed, 2005-08-17 at 23:43 -0500, Dave Rolsky wrote:
 
  But I'd really like to get this stuff done at compile time wherever 
  possible.  If I write this:
  
 validate( credit_card_number: $number );

BTW, the colon is on the left:

:credit_card_number($number)

  it should blow up at compile time, right?
 
 Does that depend on how closed you want Perl 6 to think your world is at
 compile time?

Right, because introducing new multi variant at runtime is a
desired feature.  Which is why I think closed should not be
limited to classes, but should extend to packages as well...

Thanks,
/Autrijus/


pgpx5jRaNhflL.pgp
Description: PGP signature


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 $foo is readonly;
$foo := bar();

could still be made to work.  But that means that $foo *as a container*
would have to remember if its value exists rather than relying on
the value itself knowing if it's defined.  (But that's essentially
the same distinction we make for defaults in signatures: if you pass
undef as an argument, it doesn't trigger default setting.)

In other words, you could desugar

sub foo ($a = 1) {...}

to

sub foo ($a) {
$a = 1 unless exists $a;
...
}

Larry


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/


pgp7xakdZfrUu.pgp
Description: PGP signature


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;
  ...
  }
 
 I like this.  Can we go for it, at least for this week? :)

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.

Thanks,
/Autrijus/


pgp3J1ypKaNbp.pgp
Description: PGP signature


Re: Serializing code

2005-08-18 Thread Yuval Kogman
On Thu, Aug 18, 2005 at 12:24:40 +, Ingo Blechschmidt wrote:
 Hi, 
  
 Yuval Kogman nothingmuch at woobling.org writes: 
  So now that the skeptics can see why this is important, on the 
  design side I'd like to ask for ideas on how the code serialization 
  looks... 
   
   sub { $?DOM.document.write(phello world!/p) }.emit( 
:runtime($browser_autodetect_object), 
# this can be guessed by asking the $runtime object: 
# :languagejavascript, 
   ); 
   
  This is superficially nice, 
  
 Indeed! 
  
  but here's what's missing: 
 [...] 
  
   - what exactly is a code object? 
- a wrapper for some PIL code 
- that can be executed by the runtime 
  
 Code objects may as well be executed at compile-time 
 (think macros, use and BEGIN blocks), but...: 

But it's still the runtime that runs them ;-)

Compilation has a runtime that runs the compiler, and compile-time
code. The output may be handed down to another runtime that actually
runs.

  
 sub foo { $?DOM.document.write(...) } 
 BEGIN { foo() };   # error, there's no $?DOM object 
# at compile-time! 

Unless you're compiling in the browser ;-)

 Well, you call code.emit above, so it's probably a Code 
 object, even though it calls subs and methods from the 
 Perl6::Internals namespace (or somesuch). 

Not code, but the return value of code.emit

  
   - handling of data 
- types of: 
 - globals? 
  
 I've probably misunderstood you, but can't globals, like all 
 other variables, have any type you want them to have? 

Not types in the kind of value type... Read it as:

handling of data... what types of data... global variables are
types of data

 - closures? 
  
 A subclass of Code, e.g. Bare. 

How are they stored?

 I'd like to have a pragma to switch between these policies. 

I doubt a pragma is enough - we need full introspection and fine
grained control for this, both in the lexical and the dynamic
scopes.

-- 
 ()  Yuval Kogman [EMAIL PROTECTED] 0xEBD27418  perl hacker 
 /\  kung foo master: /me supports the ASCII Ribbon Campaign: neeyah!!!



pgpBn9qG4r51e.pgp
Description: PGP signature


Re: Serializing code

2005-08-18 Thread Autrijus Tang
On Thu, Aug 18, 2005 at 08:22:20PM +0300, Yuval Kogman wrote:
  sub foo { $?DOM.document.write(...) } 
  BEGIN { foo() };   # error, there's no $?DOM object 
 # at compile-time! 
 
 Unless you're compiling in the browser ;-)

Which... is possible, and that's how I plan to support eval().

Thanks,
/Autrijus/


pgpWnA4i8m2hN.pgp
Description: PGP signature


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;
:  ...
:  }
: 
: I like this.  Can we go for it, at least for this week? :)

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 least for ordinary sub calls.  Also,
desugaring a predeclaration would tend to cloak the yadae at the end,
but maybe that's not a problem unless you use the presence of bare
yadae in the body to suppress redefinition warnings.

Larry


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 with the
symbol table is when you're compiling, so deletions could just fall into
that category.  The compiler has to be able to depend on its symbols
not going away once it's done.

Larry


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 least for ordinary sub calls.  Also,
 desugaring a predeclaration would tend to cloak the yadae at the end,
 but maybe that's not a problem unless you use the presence of bare
 yadae in the body to suppress redefinition warnings.

The full desugared form is, I think:

our foo;  # lifted to beginning of package!
...
BEGIN {
foo := a Sub is stub {
($a) := ?Internals::GETARGS();
$a = 1 unless exists $a;
# real body begins here
...
};
}

with the is stub -- not neccessarily exposed to the user level --
filled in by a parser rule, i.e. a predefined macro.

Does this sound sane?

Thanks,
/Autrijus/


pgpVR42LVke0G.pgp
Description: PGP signature


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 place is so that optimizers can install
:  constants on the caller end, at least for ordinary sub calls.  Also,
:  desugaring a predeclaration would tend to cloak the yadae at the end,
:  but maybe that's not a problem unless you use the presence of bare
:  yadae in the body to suppress redefinition warnings.
: 
: The full desugared form is, I think:
: 
: our foo;  # lifted to beginning of package!
: ...
: BEGIN {
:   foo := a Sub is stub {
:   ($a) := ?Internals::GETARGS();
:   $a = 1 unless exists $a;
:   # real body begins here
:   ...
:   };
: }
: 
: with the is stub -- not neccessarily exposed to the user level --
: filled in by a parser rule, i.e. a predefined macro.
: 
: Does this sound sane?

No, but it sounds least insane.  :-)

Larry


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() scope identifier, as with all
parameters and hoisted mid-block my() declarations.

Also, a Sub should read a sub.

Thanks,
/Autrijus/


pgp58rqXRSVNR.pgp
Description: PGP signature