Re: Supercomma! (was Re: UTF-8 and Unicode FAQ, demos)

2002-11-10 Thread fearcadi
Larry Wall <> writes:
 > But at the moment I'm thinking there's something wrong about any
 > approach that requires a special character on the signature side.
 > I'm starting to think that all the convolving should be specified
 > on the left.   So in this:
 > 
 > for parallel(@x, @y, @z) -> $x, $y, $z { ... }
 > 
 > the signature specifies that we are expecting 3 scalars to the sub,
 > and conveys no information as to whether they are generated in parallel
 > or serially.  That's entirely specified on the left.  


if I understand correctly, the main problems with Apocalypse version
of "for" are : 

* need for special meaning of ";" in the nlock signature 
* need to  specify unifying/intersection/other behaviour
* not everybody is happy with strean vs block arguments alignment
  possibilities 

one solution , to which thetread converged (??) is to essentially give
simple ways to "weave" many streams in single one, and "for" to become
always "single-stream" . this is essentially the old @a ^| @b proposal
written in english. it doesnot solve the "alignment" problem.  also ,
it seems ( but may be I am wrong ) that there is run-time overhead ,
since "weaving" if done explicitly takes additional time ~ length of
arrays . this will not happen if "for" will notice one of "weaving"
functions and optimize it away. So that means that we will have to
have "standart" set of "weaving" functions recognizable by "for" . 

so possibly we can revive the multistream for if we wrap this
behaviour around "loop" and  "given" , something like this 

loop {
given each @a  -> $x { 
given each @b  -> $y { 
given each @c  -> $z { 
last loop if undef $x|$y|$z 




this is already valid perl6 syntax if array @a have iterator method
similar hash. ( may be it is called @a.next or @a.iter  ) . 
and if "each" will notice how many arguments closure expects. 

as it is , it looks weird , and we loose the fact that "for" loop is
*single* topicalizer scope ( here we have to break 3 of them to get
out . and also the topic inside the ... is the *last* argument $z and
not the first as would be for "usual" for .

so strictly speaking , this is not "wrapping around" -- this is just
valid (??) sintax. but may be it *is* possible to somehow wrap the
multistream behaviour around loop - given pair. 

I dont know. maybe new keyword "stream" 

loop {
stream @a  -> $x,$y { 
stream @b  -> $z{ 
stream @c  -> $alpha,$beta  { 
last loop if undef $x|$y|$z 




and "stream" does not set the topicilizer scope. it seems that
"stream" is just a function .  and then it does not automatically
create a topicalizer scope.

or maybe "each" is sort of redundant inside given and we have 

loop {
given @a  -> [$x,$y   ] { 
given @b  -> [$z  ] { 
given @c  -> [$alpha,$beta] { 
last loop if undef $x|$y|$z 




but then @a will have to remember its current index. 
and given to be aware of it. may be its too much for given. 

 > 
 > for round_robin_by_3s(@x, @y, @z) -> $x, $y, $z { ... }
 > 
 > Fooling around with signature syntax for that rare case is not worth it.
 > This way, the C won't have to know anything about the signature other
 > than that it expects 3 scalar arguments.  And Simon will be happ(y|ier)
 > that we've removed an exception.
 > 

and for this type of things there is always "weaving" possibility. 

arcadi . 




Re: Primitive Vs Object types

2002-11-10 Thread Nicholas Clark
On Thu, Nov 07, 2002 at 04:16:50PM -0500, Dan Sugalski wrote:

> Basically anything you can potentially find in a symbol table or 
> lexical scratchpad will potentially be able to have a property 
> attached to it. The only way that we'll be able to reasonably 
> restrict (and optimize) the use of low-level data types is to keep 
> them out of the symbol tables, which then makes using them in string 
> evals and suchlike things somewhat problematic. (And not allowing 
> properties on them will require us to throw runtime errors) It'll 
> also make passing them in as parameters interesting, as we'd then 
> need to construct temporary full variables that held them, which'd be 
> somewhat interesting to deal with.

But surely there should be no problem passing things as parameters - with a
bit of mundane magic even taking reference to a bit should work quite nicely.
After all, perl5 can already handle the idea of not autovivifying hash lookups
passed as subroutine parameters, and assigning to substrings and substring
references:

#!/usr/local/bin/perl -w

use strict;
use Devel::Peek;

sub rroll {
  Dump $_[0];
  $_[0] x= 6;
}

sub oll {
  Dump $_[0];
  ${$_[0]} x= 4;
}

$a = "Mordor";

rroll (substr ($a, 2, 1));

print "'$a'\n";

oll (\substr ($a, -1));

print "'$a'\n";

__END__

SV = PVLV(0x1138c0) at 0x1332e8
  REFCNT = 1
  FLAGS = (PADMY,GMG,SMG,pPOK)
  IV = 0
  NV = 0
  PV = 0x133d98 "r"\0
  CUR = 1
  LEN = 2
  MAGIC = 0x10e8f0
MG_VIRTUAL = &PL_vtbl_substr
MG_TYPE = PERL_MAGIC_substr(x)
  TYPE = x
  TARGOFF = 2
  TARGLEN = 1
  TARG = 0x132f10
SV = PV(0xf4580) at 0x132f10
  REFCNT = 2
  FLAGS = (POK,pPOK)
  PV = 0x10c398 "Mordor"\0
  CUR = 6
  LEN = 7
'Morrdor'
SV = RV(0x11dee8) at 0xf4284
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x13336c
  SV = PVLV(0x1138f0) at 0x13336c
REFCNT = 2
FLAGS = (PADMY,GMG,SMG,pPOK)
IV = 0
NV = 0
PV = 0x1137e0 "r"\0
CUR = 1
LEN = 2
MAGIC = 0x10e060
  MG_VIRTUAL = &PL_vtbl_substr
  MG_TYPE = PERL_MAGIC_substr(x)
TYPE = x
TARGOFF = 10
TARGLEN = 1
TARG = 0x132f10
  SV = PV(0xf4580) at 0x132f10
REFCNT = 3
FLAGS = (POK,pPOK)
PV = 0x10c398 "Morrdor"\0
CUR = 11
LEN = 12
'Morrdo'

Nicholas Clark
-- 
INTERCAL better than perl?  http://www.perl.org/advocacy/spoofathon/