Re: Revisiting .chars (and friends) in list context

2005-06-03 Thread Stuart Cook
On 6/3/05, Joshua Gatcomb [EMAIL PROTECTED] wrote:
 What I would like to be able to do is:
 
 my $str = 'hello';
 my @chars = $str.chars; # h e l l o

I can't see this being a problem at all. For starters, the whole what
is a character issue is just as relevant to +($foo.chars) as it is to
list($foo.chars).

Secondly, the use bytes/codes/graphs/langs pragmata should be
sufficient to define what a character is in any dynamic context. The
whole should we decompose ligatures? question (raised in the earlier
thread) can be answered by the appropriate use langs.

And finally, it should be easy enough to do the efficient thing in
scalar context.


Stuart


Idea for making @, %, $ optional

2005-06-03 Thread Millsa Erlas

I have thought of an interesting idea that may allow Perl 6 to make the
$, @, and % optional on many uses of variables. This involves simply 
extending the function namespace to include all kinds of structures, and 
thus the function namespace does not require symbols, they are optional.


The intention here is not to eliminate $, @, % and friends, just make 
them optional! I believe people should be able to make the choice as to 
which way to do things, we should give the programmer as much freedom 
and as any many ways to do things as possible, not constrain them but 
empower and free them from restrictions.


Also, a goal I have tried to follow here is to implement this feature 
without affecting the existing usage grammar and rules of the Perl 6 
language at all. This is a good goal i believe, my intention is just for 
this to be an additional extension to Perl 6, not change its existing 
grammar and parsing rules at all, just expand upon it. Perl 6 is a great 
language and I like what has done so far. This is not an attempt to 
change what has already been defined, but rather provide an additional 
usage.


These are just some initial ideas, they may be able to be improved upon, 
or benefit from refinement.


**Subroutines

sub hello {
print hello!\n;
}

#**Arrays
#Define
array hello=(1, 2, 3);

#in Array context:
@array=array; #or
@array=array array;

#in Scalar context:
$element=array[1]; #or
$element=scalar array[1];

#**Hashs
#Define
hash hash1=(hello=hello1, hello2=hello2);

#In hash context=
%hash2=hash1; # or
%hash2=hash hash1;

#scalar context
$hello=hash{hello}; # or
$hello=scalar hello{hello};

#**Scalars

#Define
scalar hello=hello;

#Scalar context

$hello=hello; # or
$hello=scalar hello;

#**References
#Make reference
scalar ref=\hash; #or
scalar ref=mkref hash; #or
scalar ref=mkref hash hash;

#Dereference:

#Every ampersand after the initial one attempts to deference the
# one level of referncing:
%hash=ref;
# THis would unwrap a reference in a reference
%hash=ref;

# Dereference a reference in a hash
%hash=hash{ref};

#or
# A deref keyword for convenience:
%hash=deref ref; #or
%hash=hash scalar ref; #or
%hash=hash hash ref;

This is just an initial sketch, it may need or benefit from refinement.


[PATCH] Fix 3 of the spawnw.t failures.

2005-06-03 Thread Nigel Sandever
Further thoughts on the questions in comments invited.


njs


win32-exec.c.patch
Description: Binary data


using rules

2005-06-03 Thread BÁRTHÁZI András

Hi,

I'm working on a web templating system, and I'm wondering how should I use 
rules?


I have these defs:

rule elem {
\ wts \: ([a..z]+) \/ \
}

rule block {
\ wts \: ([a..z]+)\(.*?)\ \/ wts \: $1 \
}

I would like to execute subroutines during the evaluation. What should I 
do? Is the following the right way?


 given $template {

   s/block/{trigger_block()}/;
   s/elem/{trigger_elem()}/;

 }

How can I catch the matched elem name, and block content? I'm guessing 
that hypotetical variables can be the solution, but it says, that those 
variables should have been defined, before I use them, and it's not that 
case.


Bye,
  Andras


Re: [PATCH] Fix 3 of the spawnw.t failures.

2005-06-03 Thread Nigel Sandever
Apologies for the wrong list. Should I resend to the correct one?
njs





Re: date and time formatting

2005-06-03 Thread Rob Kinyon
 localtime() and gmtime() seem fairly core to me.  The array contexts are
 simple, and the scalar context is an RFC valid string.  Nothing too heavy
 there.  The time() function is typically only moderately useful without
 localtime().

This is true if the time() function returns a simple scalar containing
seconds since the Unix epoch. If, however, it returned a DateTime
object that numified to said value, but provided both localtime() and
gmtime() methods (and a whole lot more) ... wouldn't that be better?

Rob


Re: [PATCH] Fix 3 of the spawnw.t failures.

2005-06-03 Thread Leopold Toetsch
Nigel Sandever [EMAIL PROTECTED] wrote:

Thanks, applied - r8263

 Further thoughts on the questions in comments invited.

Yeah.

 njs

leo


Re: Idea for making @, %, $ optional

2005-06-03 Thread James Mastros
Millsa Erlas wrote:
 I have thought of an interesting idea that may allow Perl 6 to make the
 $, @, and % optional on many uses of variables. This involves simply
 extending the function namespace to include all kinds of structures, and
 thus the function namespace does not require symbols, they are optional.
 
 Also, a goal I have tried to follow here is to implement this feature
 without affecting the existing usage grammar and rules of the Perl 6
 language at all. This is a good goal i believe, my intention is just for
 this to be an additional extension to Perl 6, not change its existing
 grammar and parsing rules at all, just expand upon it. Perl 6 is a great
 language and I like what has done so far. This is not an attempt to
 change what has already been defined, but rather provide an additional
 usage.

In that case, you should be looking into how to make it a pragmata,
rather then pushing the idea on perl6-language.  It shouldn't be too
hard -- a matter of using the equivalent of perl5's UNIVERSAL::AUTOLOAD,
and the OUTER:: scope.

-=- James Mastros,
theorbtwo


Re: Idea for making @, %, $ optional

2005-06-03 Thread Millsa Erlas

James Mastros wrote:

Millsa Erlas wrote:


I have thought of an interesting idea that may allow Perl 6 to make the
$, @, and % optional on many uses of variables. This involves simply
extending the function namespace to include all kinds of structures, and
thus the function namespace does not require symbols, they are optional.

Also, a goal I have tried to follow here is to implement this feature
without affecting the existing usage grammar and rules of the Perl 6
language at all. This is a good goal i believe, my intention is just for
this to be an additional extension to Perl 6, not change its existing
grammar and parsing rules at all, just expand upon it. Perl 6 is a great
language and I like what has done so far. This is not an attempt to
change what has already been defined, but rather provide an additional
usage.



In that case, you should be looking into how to make it a pragmata,
rather then pushing the idea on perl6-language.  It shouldn't be too
hard -- a matter of using the equivalent of perl5's UNIVERSAL::AUTOLOAD,
and the OUTER:: scope.

-=- James Mastros,
theorbtwo


Does this allow the grammer rules of the language to be changed so that 
this could be implemented? How does this work?


Making this feature something that could be implemented with a pragma 
would be a fine idea.

Furthermore the idea I have had to


Re: Idea for making @, %, $ optional

2005-06-03 Thread Austin Hastings


--- James Mastros [EMAIL PROTECTED] wrote:

 Millsa Erlas wrote:
  I have thought of an interesting idea that may allow Perl 6 to make
 the
  $, @, and % optional on many uses of variables. This involves
 simply
  extending the function namespace to include all kinds of
 structures, and
  thus the function namespace does not require symbols, they are
 optional.

[...]


 In that case, you should be looking into how to make it a pragmata,
 rather then pushing the idea on perl6-language.  It shouldn't be too
 hard -- a matter of using the equivalent of perl5's
 UNIVERSAL::AUTOLOAD,
 and the OUTER:: scope.
 
   -=- James Mastros,
   theorbtwo

The fact that this keeps recurring on P6L is pretty indicative, I
think, that a lot of people don´t value the ability to have an array,
hash, and scalar of the same name quite so much as they regret the need
to respecify the types of all variables every time they´re used.

If it´s really that simple to do, then I´m willing to bet it´ll be
used early and often. Making it a part of ´core´ and in fact planning
to migrate perl in the direction of less useless line noise DOES seem
to me to be a valid task for -language.

=Austin



Re: Idea for making @, %, $ optional

2005-06-03 Thread Luke Palmer
On 6/3/05, Millsa Erlas [EMAIL PROTECTED] wrote:
 Does this allow the grammer rules of the language to be changed so that
 this could be implemented? How does this work?

Yes.  In fact, one of the big goals of perl 6 is to allow people to
mutate the grammar of the language.

If you just want scalar sigilless variables, you might do something like this:

grammar Sigilless;
is Perl::Grammar;

rule sigil () { $super := SUPER::sigil 
{ $sigil = $supersigi } 
  | null 
{ $sigil = '$' }
  }

module sigilless;
sub import () { 
SHIFT { use grammar Sigilless }
}

(Where I use SHIFT, which I just learned about from Autrijus, to
execute code in the caller's scope.)

That seems the simplest hypothetical way.  I'm not sure how that would
play with the real grammar.  We can hope it's that simple, but it will
likely take a bit more work than that.

This pretends that all sigilless variables are scalars, which might be
the best way for sigilless to go anyway given Perl 6's reference
semantics.

Luke


MMD and redefinition

2005-06-03 Thread dakkar
In Perl5, if I do:

 sub foo {return 1}
 sub foo {return 2}
 print foo();

I get a redefinition error, and a '2' on STDOUT. Can I assume this will
be the same in Perl6? i.e. can I write a test for pugs to check this?

Moreover:

 sub foo(Num $a) {return 1}
 sub foo(Str $a) {return 2}
 print foo(1),foo('a');

should have the same effect? Printing 2 twice? I don't expect MMD on
non-multi subs.

--
Dakkar - Mobilis in mobile
GPG public key fingerprint = A071 E618 DD2C 5901 9574
 6FE2 40EA 9883 7519 3F88
key id = 0x75193F88


signature.asc
Description: OpenPGP digital signature


Re: Idea for making @, %, $ optional

2005-06-03 Thread Millsa Erlas

Austin Hastings wrote:


--- James Mastros [EMAIL PROTECTED] wrote:



Millsa Erlas wrote:


I have thought of an interesting idea that may allow Perl 6 to make


the


$, @, and % optional on many uses of variables. This involves


simply


extending the function namespace to include all kinds of


structures, and


thus the function namespace does not require symbols, they are


optional.



[...]




In that case, you should be looking into how to make it a pragmata,
rather then pushing the idea on perl6-language.  It shouldn't be too
hard -- a matter of using the equivalent of perl5's
UNIVERSAL::AUTOLOAD,
and the OUTER:: scope.

-=- James Mastros,
theorbtwo



The fact that this keeps recurring on P6L is pretty indicative, I
think, that a lot of people don´t value the ability to have an array,
hash, and scalar of the same name quite so much as they regret the need
to respecify the types of all variables every time they´re used.

If it´s really that simple to do, then I´m willing to bet it´ll be
used early and often. Making it a part of ´core´ and in fact planning
to migrate perl in the direction of less useless line noise DOES seem
to me to be a valid task for -language.

=Austin



I believe that people should be given the choice as to whether to use $, 
@, or %, or not.My suggestion was one possible way to achieve making $, 
@, and % optional, while still allowing their use and not changing the 
existing perl 6 language. This is could be done by simply allowing hashs 
and arrays to be defined in the function namespace. The existing 
seperate array and hash namespaces would also be retatianed with their % 
and @ usage as well, giving people choice. I want very much to preserve 
peoples choice as to which way to do things and I do not want this 
suggestion implemented in a way if it takes away peoples right to use $, 
@ and %, or impacts Perl 6's existing grammer in other ways.


One of the reasons I suggest this idea, is indeed variables are very 
commonly used in many cases, in a program, and typing the prefix 
characters in my expierience at times is a bit of annoyance, especially 
since it requires a trip to the shift key. This is not a big problem 
with things that are seldom used in a language, but when it applies to 
something as commonly used as variables, it becomes more significant. 
Maybe its not a huge thing but it is a bit of annoyance at times to me. 
It may not be to other people thats why if people want to keep using $, 
@, And %, they should be able to, and I will still want to use them 
myself at times.


I strongly believe in TIMTOWTDI (There is more than one way to do it), 
which is one reason I like Perl, is that it gives people freedom, does 
not restrict them, and gives them flexibility and as many choices as 
possible to how to best accomplish something. I certianly hope Perl 6 
can continue, and even expand this.


(multi)subroutine names

2005-06-03 Thread dakkar
Say I have:

 multi sub foo(Array $a,Int $b) {...}
 multi sub foo(Hash %a, Int $b) {...}

and I want to (distinctly) wrap each multisub, say for testing, or AOP,
or whatever. How do I get the two different code references? As far as i
can gather from the Apocalipses and Synopses, there should be a way to
express the long name, and use that to get the ref. Is there any
proposed syntax for this? (I ask about syntax because the semantic seems
pretty clear...)

--
Dakkar - Mobilis in mobile
GPG public key fingerprint = A071 E618 DD2C 5901 9574
 6FE2 40EA 9883 7519 3F88
key id = 0x75193F88


signature.asc
Description: OpenPGP digital signature


Re: (multi)subroutine names

2005-06-03 Thread Yuval Kogman
With a meta model for code signatures you could generate a code
signature and then ask it to locate any matching multis.

For a more concrete handle on how this might look if I were king-
wait a while...  ;-)

When I have more time to finalize docs/mmd.kwid and then describe
the meta model for function signatures I promise to tell you =)

On Sat, Jun 04, 2005 at 01:20:13 +0200, dakkar wrote:
 Say I have:
 
  multi sub foo(Array $a,Int $b) {...}
  multi sub foo(Hash %a, Int $b) {...}
 
 and I want to (distinctly) wrap each multisub, say for testing, or AOP,
 or whatever. How do I get the two different code references? As far as i
 can gather from the Apocalipses and Synopses, there should be a way to
 express the long name, and use that to get the ref. Is there any
 proposed syntax for this? (I ask about syntax because the semantic seems
 pretty clear...)
 
 --
   Dakkar - Mobilis in mobile
   GPG public key fingerprint = A071 E618 DD2C 5901 9574
6FE2 40EA 9883 7519 3F88
   key id = 0x75193F88



-- 
 ()  Yuval Kogman [EMAIL PROTECTED] 0xEBD27418  perl hacker 
 /\  kung foo master: /me beats up some cheese: neeyah!



pgpeCSXevxk5a.pgp
Description: PGP signature


Re: Perl6 and support for Refactoring IDE's

2005-06-03 Thread J Matisse Enzer


On May 26, 2005, at 10:03 AM, Piers Cawley wrote:


Stevan Little [EMAIL PROTECTED] writes:

... The way I
see it working is that the language itself has a bunch of minimal 
hooks that
get triggered by various phases of compilation etc. Your editor then 
becomes
something that instruments the compiler in such a way that loading a 
file for
editing compiles it, but the compilation process hangs populates the 
data

structures you need for editing.


Sorry to have dropped out of this thread for so long. I'm glad to see 
such smart people thinking about this too.


I like what Piers is suggesting, not because I am in any way qualified 
to say how practical it is, but because the idea he presents really 
would make it possible to have much better tools for Perl.


The idea that the language will allow an editor (an IDE) to really find 
out the knowable information about the source code is the crucial 
thing.


Frankly, there are huge improvements in tools possible for Perl5, just 
by accepting some limitations - we probably cannot duplicate the 
refactoring support available for Java in Perl5, but we can do one heck 
of a lot better than just extract subroutine (which is the *only* 
refactoring available now in a Perl IDE.)


We are still not even at the simple things should be easy stage of a 
refactoring IDE for Perl, and I'd be happy to at least get there before 
worrying about the hard things are possible stage :-)


Once I saw how cool the features in something like Eclipse are for 
another language it really has made me see how far behind Perl is in 
this area. I'm really scared that Perl will be an unacceptable choice 
for larger projects in less than a two years.


-Matisse

---
Matisse Enzer [EMAIL PROTECTED]
http://www.matisse.net/  - http://www.eigenstate.net/
415-225-6703 (work/cellphone)
415-401-8325 (home)