Re: Parrot as an extension language

2005-05-20 Thread Colin Paul Adams
> "Dan" == Dan Sugalski <[EMAIL PROTECTED]> writes:

Dan> So, I see four real options:

Dan> 1) Someone fixes the Eiffel interface generator to understand
Dan> C variadic functions.  2) We provide a function and method
Dan> call interface that assumes you've already pre-filled in the
Dan> registers according to parrot's calling conventions 3) We
Dan> build some sort of really simple call interface that takes an
Dan> array PMC with the parameters stuffed into it 4) Parrot
Dan> provides some sort of facility to autogenerate shim functions
Dan> based on a passed-in signature

I was thinking of option (3).

Dan> #s 2&3 are sub-optimal,
Dan> and either require some work on the caller's part (or changes
Dan> to the interface generator) or kinda limit what you can do.

It's inevitable that the caller has to do some work in a strongly
typed language.

Dan> Teaching the interface generator about variadic functions is
Dan> probably the easiest thing -- in principle it's not that
Dan> tough (Hey, I did one, I get to say that :) though that does
Dan> depend on what the code in the interface generator looks
Dan> like.

But what code can you possibly generate if the source language is
strongly typed? You can't generate an infinite number of function
definitions.

-- 
Colin Adams
Preston Lancashire


Re: reduce metaoperator on an empty list

2005-05-20 Thread Matt Fowles
Mark~

On 5/20/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 
> > Mark A. Biggar wrote:
> > > Well the identity of % is +inf (also right side only).
> >
> > I read $n % any( $n..Inf ) == $n. The point is there's no
> > unique right identity and thus (Num,%) disqualifies for a
> > Monoid. BTW, the above is a nice example where a junction
> > needn't be preserved :)
> 
> If as usual the definition of a right identity value e is that a op e = a for 
> all a,
> then only +inf works.  Besdies you example should have been;
> $n % any (($n+1)..Inf),  $n % $n = 0.
> 
> > > E.g. if X >
> > Sorry, is it the case that $x = $y < $z might put something else
> > but 0 or 1 into $x depending on the order relation between $y and $z?
> 
> Which is one reason why I siad that it might not make sense to define the 
> chaining ops in terms of the associtivity of the binary ops,  But as we are 
> interested in what [<] over the empty list shoud return , the identity (left 
> or right) of '<' is unimportant as I think that should return false as there 
> is nothing to be less then anything else.  Note that defaulting to undef 
> therefore works in that case.

On the contrary a mathematician would say that the empty list is
monotonically increasing (vacuously) and the answer should be true.

Matt
-- 
"Computer Science is merely the post-Turing Decline of Formal Systems Theory."
-???


Re: pcre.t failure

2005-05-20 Thread Dino Morelli
On Fri, 20 May 2005, chromatic wrote:

>On Fri, 2005-05-20 at 17:49 -0400, Dino Morelli wrote:
>
>> r8136, I'm seeing this test failure:
>>
>> $ perl t/harness t/library/pcre.t
>>
>> t/library/pcreCan't use string ("Test::Builder") as a HASH ref while
>> "strict refs" in use at lib/Test/Builder.pm line 304.
>
>This is a feature of the Test-Simple update I did yesterday.
>
>I bet $has_pcre is false for you and you're hitting the skip on line 29.
>That's a funky piece of code anyway.
>
>Does the attached patch fix it for you?
>

That did it, test skipped. Thank you!


>-- c
>

-Dino

-- 
 .~.Dino Morelli
 /V\email: [EMAIL PROTECTED]
/( )\   weblog: http://categorically.net/d/blog/
^^-^^   preferred distro: Debian GNU/Linux  http://www.debian.org


Re: reduce metaoperator on an empty list

2005-05-20 Thread mark . a . biggar

> Mark A. Biggar wrote:
> > Well the identity of % is +inf (also right side only).
> 
> I read $n % any( $n..Inf ) == $n. The point is there's no
> unique right identity and thus (Num,%) disqualifies for a
> Monoid. BTW, the above is a nice example where a junction
> needn't be preserved :)

If as usual the definition of a right identity value e is that a op e = a for 
all a,
then only +inf works.  Besdies you example should have been;
$n % any (($n+1)..Inf),  $n % $n = 0. 

> > E.g. if X 
> Sorry, is it the case that $x = $y < $z might put something else
> but 0 or 1 into $x depending on the order relation between $y and $z?

Which is one reason why I siad that it might not make sense to define the 
chaining ops in terms of the associtivity of the binary ops,  But as we are 
interested in what [<] over the empty list shoud return , the identity (left or 
right) of '<' is unimportant as I think that should return false as there is 
nothing to be less then anything else.  Note that defaulting to undef therefore 
works in that case.

--
Mark Biggar
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]




[perl #35903] [BUG] pcre.t failure

2005-05-20 Thread via RT
# New Ticket Created by  jerry gay 
# Please include the string:  [perl #35903]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/rt3/Ticket/Display.html?id=35903 >


i'm seeing the same failure, with perl 5.8.6, msvc 7.1, and win32

-- Forwarded message --
From: Dino Morelli <[EMAIL PROTECTED]>
Date: May 20, 2005 2:49 PM
Subject: pcre.t failure
To: Perl 6 Internals list 


r8136, I'm seeing this test failure:

$ perl t/harness t/library/pcre.t

t/library/pcreCan't use string ("Test::Builder") as a HASH ref while
"strict refs" in use at lib/Test/Builder.pm line 304.
# Looks like your test died before it could output anything.
t/library/pcredubious
   Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED test 1
   Failed 1/1 tests, 0.00% okay
Failed Test  Stat Wstat Total Fail  Failed  List of Failed
---
t/library/pcre.t  255 65280 12 200.00%  1
Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay.


My system is Linux with Perl 5.8.4
>From chat on #parrot, looks like not everybody is seeing this happen.


-Dino

--
 .~.Dino Morelli
 /V\email: [EMAIL PROTECTED]
/( )\   weblog: http://categorically.net/d/blog/
^^-^^   preferred distro: Debian GNU/Linux  http://www.debian.org


[perl #35900] [PATCH] skip dynclasses, spawnw tests on win32

2005-05-20 Thread via RT
# New Ticket Created by  jerry gay 
# Please include the string:  [perl #35900]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/rt3/Ticket/Display.html?id=35900 >


dynclasses and spawnw have been busted on win32 for some time now.
with this patch, these annoying test failures will be skipped on
win32. it should be noted that this patch modifies Parrot::Test to
take advantage of Test::More's plan function, which makes 'skip_all'
possible.

there are other, unrelated test failures on win32 after this patch,
which are being investigated.
~jerry


dynclass-spawnw.patch
Description: Binary data


RE: Graphing tool for PerlGuts Illustrated

2005-05-20 Thread Jan Dubois
On Fri, 20 May 2005, Brian Ingerson wrote:
> On 20/05/05 22:06 +0300, Yuval Kogman wrote:
> > Hola,
> >
> > In PerlGuts Illustrated you have some very pretty diagrams...
> >
> > Could you please hint me on what you generated them with, so that I
> > can use it for the forthcomming PugsGuts Illustrated?
>
> I used to sit next to Gisle at ActiveState.
>
> IIRC(AIDRC), he hand-hacked postscript files for those diagrams :P

After drawing them with a pen on graphing paper first to get the
coordinates right.  The PostScript sources are all on CPAN too:

http://search.cpan.org/~gaas/illguts-0.09/

Cheers,
-Jan





Re: pcre.t failure

2005-05-20 Thread chromatic
On Fri, 2005-05-20 at 17:49 -0400, Dino Morelli wrote:

> r8136, I'm seeing this test failure:
> 
> $ perl t/harness t/library/pcre.t
> 
> t/library/pcreCan't use string ("Test::Builder") as a HASH ref while
> "strict refs" in use at lib/Test/Builder.pm line 304.

This is a feature of the Test-Simple update I did yesterday.

I bet $has_pcre is false for you and you're hitting the skip on line 29.
That's a funky piece of code anyway.

Does the attached patch fix it for you?

-- c


Index: t/library/pcre.t
===
--- t/library/pcre.t	(revision 8136)
+++ t/library/pcre.t	(working copy)
@@ -26,7 +26,8 @@
 STDERR => '/dev/null') == 0;
 
 SKIP: {
-skip("no pcre-config", Test::Builder->expected_tests()) unless $has_pcre;
+skip("no pcre-config", Test::Builder->new()->expected_tests())
+unless $has_pcre;
 
 ## 1
 pir_output_is( <<'CODE', <<'OUT', 'soup to nuts' );


pcre.t failure

2005-05-20 Thread Dino Morelli
r8136, I'm seeing this test failure:

$ perl t/harness t/library/pcre.t

t/library/pcreCan't use string ("Test::Builder") as a HASH ref while
"strict refs" in use at lib/Test/Builder.pm line 304.
# Looks like your test died before it could output anything.
t/library/pcredubious
Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED test 1
Failed 1/1 tests, 0.00% okay
Failed Test  Stat Wstat Total Fail  Failed  List of Failed
---
t/library/pcre.t  255 65280 12 200.00%  1
Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay.


My system is Linux with Perl 5.8.4
>From chat on #parrot, looks like not everybody is seeing this happen.


-Dino

-- 
 .~.Dino Morelli
 /V\email: [EMAIL PROTECTED]
/( )\   weblog: http://categorically.net/d/blog/
^^-^^   preferred distro: Debian GNU/Linux  http://www.debian.org


Re: Parrot as an extension language

2005-05-20 Thread C. Scott Ananian
On Fri, 20 May 2005, Dan Sugalski wrote:
So, I see four real options:
1) Someone fixes the Eiffel interface generator to understand C variadic 
functions.
2) We provide a function and method call interface that assumes you've 
already pre-filled in the registers according to parrot's calling 
conventions
3) We build some sort of really simple call interface that takes an array 
PMC with the parameters stuffed into it
4) Parrot provides some sort of facility to autogenerate shim functions 
based on a passed-in signature
See
http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/functions.html#wp4256
I think what's missing currently is the interface which takes the 'jvalue 
*' in the JNI interface; ie option #3 (if I understand you correctly).
In my implementation of the JNI (for the FLEX java compiler's runtime)
I implemented everything in terms of this 'MethodA' variant; the '...'
version easily packs up to a va_list, and then the va_list version needs 
to parse the method/sub's signature and generate an appropriate
array of PMCs which can be passed to the (canonical) 'MethodA' version.
 --scott

AMTHUG Waco, Texas ODEARL overthrow assassinate Sabana Seca Albanian 
strategic Blair blowfish atomic AP GPFLOOR AVBUSY cryptographic pending
 ( http://cscott.net/ )


Re: lazy context

2005-05-20 Thread Yuval Kogman
On Fri, May 20, 2005 at 17:15:24 -0400, C. Scott Ananian wrote:

> This is very elegant.  It might be worthwhile for someone to attempt to 
> define a 'core 
> perl' set of operators, etc, so that the 'rest of perl' can be defined in 
> perl proper...

Have a look at synopsis 29... For documentation purposes it
"implements" lots of perl 6's non-core core.

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me groks YAML like the grasshopper: neeyah!!



pgpIoS7BoQeTi.pgp
Description: PGP signature


Re: Parrot as an extension language

2005-05-20 Thread C. Scott Ananian
On Fri, 20 May 2005, Colin Paul Adams wrote:
   Leopold>  interpreter, PMC *sub, const char *sig, va_list args)>
And as for hand-writing interfaces, I'm not sure I know HOW to create
a va_list.
void *Parrot_runops_fromc_argsN(Parrot_Interp i, PMC *sub,
const char *sig, ...) {
  void *result;
  va_list ap;
  va_start(ap, sig);
  result = Parrot_runops_fromc_arglist(i,sub,sig,ap);
  va_end(ap);
  return result;
}
void *Parrot_runops_fromc_args0(Parrot_Interp i, PMC *sub, const char *sig){
  return Parrot_runops_fromc_argsN(i, sub, sig);
}
void *Parrot_runops_fromc_args1(Parrot_Interp i, PMC *sub, const char *sig,
void **args){
  return Parrot_runops_fromc_argsN(i, sub, sig, args[0]);
}
void *Parrot_runops_fromc_args2(Parrot_Interp i, PMC *sub, const char *sig,
void **args){
  return Parrot_runops_fromc_argsN(i, sub, sig, args[0], args[1]);
}
/* .. etc .. */
typedef void (*pf_t)(Parrot_Interp i, PMC *sub, const char *sig, void **args);
void *Parrot_runops_fromc_args(Parrot_Interp i, PMC *sub, const char *sig,
   void **args, int num_args){
  static const pf_t dispatch[] = { Parrot_runops_fromc_args0,
   Parrot_runops_fromc_args1,
   Parrot_runops_fromc_args2,
   /* ... etc ... */ };
  assert(num_args < (sizeof(dispatch)/sizeof(*dispatch)));
  return (dispatch[num_args])(i, sub, sig, args);
}

See?  Easy! =)
Of course, if your arguments array is not homogeneous, this scheme gets 
more complicated (that's why the va_list is being used to start with),
but it's still quite possible.  It is very rare to find functions of more 
than, say, 10 arguments.
 --scott

Echelon JMBLUG GRALLSPICE cryptographic KUGOWN Waihopai HBDRILL ESODIC 
SEAL Team 6 Nader Bush LICOZY RUCKUS Sabana Seca ODEARL COBRA JANE
 ( http://cscott.net/ )


Re: Graphing tool for PerlGuts Illustrated

2005-05-20 Thread 'Yuval Kogman'
On Fri, May 20, 2005 at 14:20:04 -0700, Jan Dubois wrote:

> > IIRC(AIDRC), he hand-hacked postscript files for those diagrams :P
> 
> After drawing them with a pen on graphing paper first to get the
> coordinates right.  The PostScript sources are all on CPAN too:

I am impressed and humbled.

I will do the same. Up to finishing the drawings. Then I will scan
them and leave it at that... Maybe someone else with more
graphics-fu can save me ;-)

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /methinks long and hard, and runs away: neeyah!!!



pgpuFOxxmcTOE.pgp
Description: PGP signature


Re: lazy context

2005-05-20 Thread Patrick R. Michaud
On Fri, May 20, 2005 at 05:15:24PM -0400, C. Scott Ananian wrote:
> On Fri, 20 May 2005, Yuval Kogman wrote:
> 
> >then it is not finalized into a real value. Here's how the range
> >operator would be implemented:
> >
> > sub &infix:<..> ($from, $to where { $to < $from }){ reverse $to .. 
> > $from }
> > sub &infix:<..> ($from, $to) { lazy gather {
> > while ($from <= $to) {
> > take($from++);
> > }
> > }}
> 
> This is very elegant.  It might be worthwhile for someone to attempt to 
> define a 'core perl' set of operators, etc, so that the 'rest of perl' can 
> be defined in perl proper...

It may be fairly tough to identify what's "core" and what isn't.
But in general I'd propose that if something can be easily and 
efficiently defined as a perl 6 sub or method, then let's at least
document it that way (if not actually implement it that way) and
later we'll optimize the things that need optimizing.

Pm


Re: Parrot as an extension language

2005-05-20 Thread Leopold Toetsch
Dan Sugalski wrote:
There are interfaces in the extension system to get a void * and length 
back from a PMC when fetching string data out, but I see we don't have 
that for plain strings. I'll probably fix that this weekend if someone 
doesn't beat me to it.
There was a disucssion WRT that on #parrot today:
Autrijus had implemented:
const char *Parrot_string_cstring(Interp *, const STRING *);
This was in string_funcs.h only albeit it didn't have an Interp* 
argument originally. It returns str->strstart, which is currently not 
quite right or safe.

We can do one of:
a) return the length additionally to strstart
b) internally delimit "C-strings" by an invisibile NUL.
And we have to limit this function for fixed8-encoded strings and make 
clear that the returned string is immutable.

For other cases we have already string_to_cstring (and an interface in 
extend.h) which returns a malloced copy of the string.

leo


Re: lazy context

2005-05-20 Thread C. Scott Ananian
On Fri, 20 May 2005, Yuval Kogman wrote:
then it is not finalized into a real value. Here's how the range
operator would be implemented:
sub &infix:<..> ($from, $to where { $to < $from }){ reverse $to .. 
$from }
sub &infix:<..> ($from, $to) { lazy gather {
while ($from <= $to) {
take($from++);
}
}}
This is very elegant.  It might be worthwhile for someone to attempt to 
define a 'core perl' set of operators, etc, so that the 'rest of perl' can 
be defined in perl proper...
 --scott

Pakistan FBI assassination Israel AVBUSY BATF ODEARL [Hello to all my fans in domestic surveillance] 
interception domestic disruption KMFLUSH ODENVY IDEA DES MI5 arrangements
 ( http://cscott.net/ )


Re: Parrot as an extension language

2005-05-20 Thread Dan Sugalski
At 4:35 PM -0400 5/20/05, C. Scott Ananian wrote:
On Fri, 20 May 2005, Dan Sugalski wrote:
Well, mostly. string->cstring conversion is potentially lossy, if 
for no other reason than embedded nulls will get in your way. I see 
we're not exposing anything to do that, though, which we ought to 
fix.
pascal-style strings (ie, char* and length) are the canonical way to
fix this.  C code generally doesn't have too much trouble replacing
strcpy with memcpy, etc...
That's what parrot strings are. (Well, a bit more than that, since we 
carry around encoding and charset information as well) It's only when 
you drop down to C-style "blob 'o memory with an in-band EOS marker" 
that you run into trouble.

There are interfaces in the extension system to get a void * and 
length back from a PMC when fetching string data out, but I see we 
don't have that for plain strings. I'll probably fix that this 
weekend if someone doesn't beat me to it.
--
Dan

--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk


Re: Graphing tool for PerlGuts Illustrated

2005-05-20 Thread Brian Ingerson
On 20/05/05 22:06 +0300, Yuval Kogman wrote:
> Hola,
> 
> In PerlGuts Illustrated you have some very pretty diagrams...
> 
> Could you please hint me on what you generated them with, so that I
> can use it for the forthcomming PugsGuts Illustrated?

I used to sit next to Gisle at ActiveState.

IIRC(AIDRC), he hand-hacked postscript files for those diagrams :P

Cheers, Brian


Re: Parrot as an extension language

2005-05-20 Thread C. Scott Ananian
On Fri, 20 May 2005, Dan Sugalski wrote:
Well, mostly. string->cstring conversion is potentially lossy, if for no 
other reason than embedded nulls will get in your way. I see we're not 
exposing anything to do that, though, which we ought to fix.
pascal-style strings (ie, char* and length) are the canonical way to
fix this.  C code generally doesn't have too much trouble replacing
strcpy with memcpy, etc...
 --scott
Sudan insurgent SGUAT HTKEEPER LCFLUTTER chemical agent hack Semtex 
Iraq JMWAVE interception $400 million in gold bullion KUPALM SSBN 731
 ( http://cscott.net/ )


Re: [unclassified] Re: reduce metaoperator on an empty list

2005-05-20 Thread Edward Cherlin
On Thursday 19 May 2005 19:51, Sam Vilain wrote:
> Edward Cherlin wrote:
> > Here is the last answer from Ken Iverson, who invented
> > reduce in the 1950s, and died recently.
> > file:///usr/share/j504/system/extras/help/dictionary/intro28
> >.htm

http://www.jsoftware.com/books/help/dictionary/intro28.htm

Sorry. It's exactly the same material the provide with their 
software, so I got confused.

>[snip]
>
> Thanks for bringing in a little history to the discussion. 
> Those links are all local to your system; do you have internet
> reachable versions of them?
>
> Cheers,
> Sam.

-- 
Edward Cherlin
Generalist & activist--Linux, languages, literacy and more
"A knot! Oh, do let me help to undo it!"
--Alice in Wonderland
http://cherlin.blogspot.com


Re: Parrot as an extension language

2005-05-20 Thread Dan Sugalski
At 8:10 PM +0100 5/20/05, Colin Paul Adams wrote:
 > "Leopold" == Leopold Toetsch <[EMAIL PROTECTED]> writes:
Leopold> Colin Paul Adams <[EMAIL PROTECTED]> wrote:
>> I have a problem with this - namely that the function is
>> variadic, and the interface generator can't cope with this.
Leopold> Have a look at src/inter_run.c e.g.
Leopold>  interpreter, PMC *sub, const char *sig, va_list args)>
Despite what I said before, this is actually worse than
Parrot_call_sub.
The interface generator ignores it completely, rather than generating
an incorrect signature (I suppose that's an improvement really, except
then it can't even be used for subroutines which accept zero
arguments).
Then the question is: What'd work? There are limits to what's going 
to be useful if you're not in a position to do full variadic function 
calls, and I'm not sure that we should put too many special cases in. 
On the other hand, I know how much of a pain this can be, since I did 
the first implementation of parrot's NCI interface, which has the 
same sorts of issues to deal with.

So, I see four real options:
1) Someone fixes the Eiffel interface generator to understand C 
variadic functions.
2) We provide a function and method call interface that assumes 
you've already pre-filled in the registers according to parrot's 
calling conventions
3) We build some sort of really simple call interface that takes an 
array PMC with the parameters stuffed into it
4) Parrot provides some sort of facility to autogenerate shim 
functions based on a passed-in signature

None of them are particularly good, and they'll all potentially cause 
you problems with an interface generator. 1's the best (and not just 
because it means we don't have to do anything :) but that's probably 
untenable. #4 is probably the next easiest thing, but I'm not sure 
that you could use that without at least some tweaks to the interface 
generator, and it'd be a bit dodgy on systems we don't have JIT 
capabilities on. #s 2&3 are sub-optimal, and either require some work 
on the caller's part (or changes to the interface generator) or kinda 
limit what you can do.

Teaching the interface generator about variadic functions is probably 
the easiest thing -- in principle it's not that tough (Hey, I did 
one, I get to say that :) though that does depend on what the code in 
the interface generator looks like.
--
Dan

--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk


Re: Parrot as an extension language

2005-05-20 Thread Leopold Toetsch
Colin Paul Adams wrote:
"Leopold" == Leopold Toetsch <[EMAIL PROTECTED]> writes:

Leopold>  interpreter, PMC *sub, const char *sig, va_list args)>
Despite what I said before, this is actually worse than
Parrot_call_sub.
The interface generator ignores it completely, 
What interface generator?
... rather than generating
an incorrect signature (I suppose that's an improvement really, except
then it can't even be used for subroutines which accept zero
arguments).
signature letter "v" - void.
And as for hand-writing interfaces, I'm not sure I know HOW to create
a va_list.
see the various usages in the mentioned file.
leo


Re: hyperoperators and multi-dimensional datastructures

2005-05-20 Thread Edward Cherlin
On Thursday 19 May 2005 12:48, Uri Guttman wrote:
> > "LP" == Luke Palmer <[EMAIL PROTECTED]> writes:
>
>   LP> On 5/18/05, Anthony Heading <[EMAIL PROTECTED]> wrote:
>   >> Is there a way to target hyperoperators at different axes
>   >> of a multi-dimensional array?  This is an attractive
>   >> feature of various APL-like languages, viz. e.g. in J:
>   >>
>   >> a =. 2 5 $ i. 7  - a simple 2-by-5 array
>   >> a
>   >> 0 1 2 3 4   - like this
>   >> 5 6 0 1 2
>   >>
>   >>
>   >> +/"1 a  - sum reduce over axis 1
>   >> 10 14

That is, break the array into rows, and reduce each row.

>   LP> [+]<< @a
>
>   >> +/"2 a  - sum reduce over axis 2
>   >> 5 7 2 4 6

Actually, that's sum reduce over planes, which gives the default 
behavior when applied to a single plane, of breaking the plane 
into rows, and adding the rows to each other. The result is the 
same as from +/a .

The rank conjunction (") is tersely explained at
http://www.jsoftware.com/books/help/dictionary/intro20.htm
and more fully in The J Primer, J for C Programmers, and other 
online publications at
http://www.jsoftware.com/publications_books.htm

>   LP> Can't think of any for this one.  Or maybe it's this one
> that I can LP> think of it for, and the other one which I
> can't.
>
> i can't spit out the syntax but here is the conceptual way i
> would do it. we do have multidimensional slices so we could
> grab each slice (maybe with zip?) and pass that to [+] and
> then grab the list of results back into a array/matrix with
> one less dimension than the original.

Exactly how Iverson conceived rank for reduction.

> so it would be something like this: (very wacko pseudo code):
>
>   @in[ * ; 2 ; * ] ==>
>   map [+] ==>
>   @out
>
> that was an (bad) attempt to slice the third entry in the
> second dimension to be summed.

You might find it useful to examine this published source code 
for an early version of J
http://www.math.uwaterloo.ca/apl_archives/j/early_j/src/j7/
to see how Iverson's crew implemented rank.

The numbering is confusing, because they restarted at some point, 
so J5.0.4 is current.

>   LP> I think we're beginning to re-invent PDL.  

APL and J, too.

>   Poorly. 

Amen.

> but is there a p6 pdl yet? they may not need much with
> multi-dim ops, slices, hyper and reduce all built in! also
> with type int (patform ints), they can get the dense storage
> needed (but losing any dimensional flexibility).
>
> uri

-- 
Edward Cherlin
Generalist & activist--Linux, languages, literacy and more
"A knot! Oh, do let me help to undo it!"
--Alice in Wonderland
http://cherlin.blogspot.com


Re: Complex Arithmetic

2005-05-20 Thread Edward Cherlin
On Thursday 19 May 2005 09:39, Luke Palmer wrote:
> On 5/19/05, Edward Cherlin <[EMAIL PROTECTED]> wrote:
> > It turns out that the domain and range and the location of
> > the cut lines have to be worked out separately for different
> > functions. Mathematical practice is not entirely consistent
> > in making these decisions, but in programming, there seems
> > to be widespread agreement that the shared definitions used
> > in the APL, Common LISP, and Ada standards are the best
> > available.
> >
> > Do we want to get into all of this in Perl6?
>
> I'm not really sure I know what you mean by "do we want to get
> into all of this?".  If we're going to have a Complex class,
> we have to. But "getting into it" might involve saying that
> APL, CL, and Ada are the best, so we use those.  This is the
> kind of problem where, if someone wants to get more precise,
> they turn to CPAN.
>
> Luke

 Math::Complex - complex numbers and associated mathematical 
functions
http://cpan.uwinnipeg.ca/htdocs/perl/Math/Complex.html

lists the complex functions, but with no information given 
there on domain, range (principal values), and branch cuts. 

The APL standard costs $350 from ANSI or 260 Swiss Francs from 
ISO, but the Common Lisp Hyperspec is available online for free.
http://www.lispworks.com/documentation/HyperSpec/
as is the Ada Reference Manual. The CL and Ada definitions are 
incomplete. I'll have to find a copy of the APL standard.

log(z) 
CL Hyperspec: "The branch cut for the logarithm function of one 
argument (natural logarithm) lies along the negative real axis, 
continuous with quadrant II. The domain excludes the origin."
Thus the range would be defined as -pi < Im(log(z)) <= pi

sin(z)
CL Hyperspec: Not defined for complex arguments.

Ada RF says:
The functions have their usual mathematical meanings. 
However, the arbitrariness inherent in the placement of branch 
cuts, across which some of the complex elementary functions 
exhibit discontinuities, is eliminated by the following 
conventions: 
(13)

* The imaginary component of the result of the Sqrt and 
Log functions is discontinuous as the parameter X crosses the 
negative real axis. 

(14)

* The result of the exponentiation operator when the left 
operand is of complex type is discontinuous as that operand 
crosses the negative real axis. 

(15)

* The real (resp., imaginary) component of the result of 
the Arcsin and Arccos (resp., Arctanh) functions is 
discontinuous as the parameter X crosses the real axis to the 
left of -1.0 or the right of 1.0. 

(16)

* The real (resp., imaginary) component of the result of 
the Arctan (resp., Arcsinh) function is discontinuous as the 
parameter X crosses the imaginary axis below -i or above i. 

(17)

* The real component of the result of the Arccot function 
is discontinuous as the parameter X crosses the imaginary axis 
between -i and i. 

(18)

* The imaginary component of the Arccosh function is 
discontinuous as the parameter X crosses the real axis to the 
left of 1.0. 

(19)

* The imaginary component of the result of the Arccoth 
function is discontinuous as the parameter X crosses the real 
axis between -1.0 and 1.0. 

(20)
The computed results of the mathematically multivalued 
functions are rendered single-valued by the following 
conventions, which are meant to imply the principal branch: 
(21)

* The real component of the result of the Sqrt and 
Arccosh functions is nonnegative. 

(22)

* The same convention applies to the imaginary component 
of the result of the Log function as applies to the result of 
the natural-cycle version of the Argument function of 
Numerics.Generic_Complex_Types (see G.1.1). 

(23)

* The range of the real (resp., imaginary) component of 
the result of the Arcsin and Arctan (resp., Arcsinh and Arctanh) 
functions is approximately -Pi/2.0 to Pi/2.0. 

(24)

* The real (resp., imaginary) component of the result of 
the Arccos and Arccot (resp., Arccoth) functions ranges from 0.0 
to approximately Pi. 

(25)

* The range of the imaginary component of the result of 
the Arccosh function is approximately -Pi to Pi. 
-- 
Edward Cherlin
Generalist & activist--Linux, languages, literacy and more
"A knot! Oh, do let me help to undo it!"
--Alice in Wonderland
http://cherlin.blogspot.com


Re: Parrot as an extension language

2005-05-20 Thread Colin Paul Adams
> "Leopold" == Leopold Toetsch <[EMAIL PROTECTED]> writes:

Leopold> Colin Paul Adams <[EMAIL PROTECTED]> wrote:
>> I have a problem with this - namely that the function is
>> variadic, and the interface generator can't cope with this.

Leopold> Have a look at src/inter_run.c e.g.

Leopold>  interpreter, PMC *sub, const char *sig, va_list args)>

Despite what I said before, this is actually worse than
Parrot_call_sub.
The interface generator ignores it completely, rather than generating
an incorrect signature (I suppose that's an improvement really, except
then it can't even be used for subroutines which accept zero
arguments).
And as for hand-writing interfaces, I'm not sure I know HOW to create
a va_list.
-- 
Colin Adams
Preston Lancashire


Graphing tool for PerlGuts Illustrated

2005-05-20 Thread Yuval Kogman
Hola,

In PerlGuts Illustrated you have some very pretty diagrams...

Could you please hint me on what you generated them with, so that I
can use it for the forthcomming PugsGuts Illustrated?

Grazie!

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me kicks %s on the nose: neeyah!



pgpxUfENS3KQc.pgp
Description: PGP signature


Re: How do I... invoke a method reference

2005-05-20 Thread TSa (Thomas Sandlaß)
C. Scott Ananian wrote:
I think Ingo was trying to explicitly specify the normally-implicit 
invocant; ie, invoke the method via the reference *without* using a '.'.
If this is possible (and I think it is), it's not (yet) clear what the
syntax would be.  Maybe
$ref(Foo.new():)
I think for MMD calls no : is needed. The dispatcher should find the best
match for the complete set of args anyway. The problem is to hit the
intended recipient when there's no argument other than $_ which was just
recently re-instated as the default invocant. Even though a simple $ref.()
might know from the type of $ref which is 'Ref of Method of Foo', to
invoke a method on $_, I would expect a type error unless $_ happens to 
refer to a subtype of Foo.

Since Ingo's simple example doesn't need an invocant at all the following
might work
  class Foo
  {
 method bar(Any:) { 42 }
 method baz() { &bar }
  }
But I think it's better to make &bar a sub.
--
TSa (Thomas Sandlaß)


lazy context

2005-05-20 Thread Yuval Kogman
Hola,

Some of us on #perl6 bitched once more about how lazy will make our
IO brain hurt a lot.

The concensus is that a lazy context has not been discussed yet.

Here is a proposal for lazyness defined with coroutines.

we have a lazy modifier:

my $a = lazy { get_value(5, 10) };
my @array = lazy gather { ... take ... };

What it returns is a proxy object that vivifies to a true value, or
in the case of list context lazy, a proxy object array that
implements a generator.

The rvalue of the lazy context modifier is turned into a coro
closure, and is invoked only when the value is accessed.

Moreover, in lazy context, if the coro yields instead of finishing,
then it is not finalized into a real value. Here's how the range
operator would be implemented:

sub &infix:<..> ($from, $to where { $to < $from }){ reverse $to .. 
$from }
sub &infix:<..> ($from, $to) { lazy gather {
while ($from <= $to) {
take($from++);
}
}}

In this case, take in lazy context gather would yield.

The only "builtin" feature that needs to be added is that coroutines
can masquerade as their return value, and not a code reference, but
AFAIK proxy objects will give us that anyway, right?

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me wields bonsai kittens: neeyah



pgpTt6lX8kOqt.pgp
Description: PGP signature


Re: Parrot as an extension language

2005-05-20 Thread Dan Sugalski
At 1:15 AM +0800 5/21/05, Autrijus Tang wrote:
On Sat, May 21, 2005 at 12:53:15AM +0800, Autrijus Tang wrote:
 Yeah, I bumped against that too.  You need to look at the "strstart"
 field in the ParrotString struct.
 In Haskell I use:
 peekCString =<< #{peek STRING, strstart} s5
Actually, never mind; string_to_cstring is the way to go.
Well, mostly. string->cstring conversion is potentially lossy, if for 
no other reason than embedded nulls will get in your way. I see we're 
not exposing anything to do that, though, which we ought to fix.
--
Dan

--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk


Re: reduce metaoperator on an empty list

2005-05-20 Thread TSa (Thomas Sandlaß)
Mark A. Biggar wrote:
Well the identity of % is +inf (also right side only).
I read $n % any( $n..Inf ) == $n. The point is there's no
unique right identity and thus (Num,%) disqualifies for a
Monoid. BTW, the above is a nice example where a junction
needn't be preserved :)

E.g. if XSorry, is it the case that $x = $y < $z might put something else
but 0 or 1 into $x depending on the order relation between $y and $z?
--
TSa (Thomas Sandlaß)


Re: wanted: hash stress tests

2005-05-20 Thread Leopold Toetsch
Uri Guttman wrote:
"LT" == Leopold Toetsch <[EMAIL PROTECTED]> writes:

  LT> I'm currently rewriting the hash implementation in src/hash.c. The
  LT> new hash structure has just one piece of malloced memory with
  LT> bucket pointers and buckets in one piece.
here is an odd thought to add to that. since your hash is a single hunk
of ram, you could use offsets inside it instead of pointers. that means
it could be both shareable (given locks) and even writable to disk. 
I don't see the difference WRT shareable, but yes, the memory hunk could 
be written at once for freezing, which may save some cycles. More 
importantly it doesn't need relocation during hash_expand(), if offsets 
are calculated from start of mem.

With some benchmarks we can see, which is better, but using offsets 
seems to be a good idea.

uri
Thanks,
leo


Re: Parrot as an extension language

2005-05-20 Thread Autrijus Tang
On Sat, May 21, 2005 at 12:53:15AM +0800, Autrijus Tang wrote:
> Yeah, I bumped against that too.  You need to look at the "strstart"
> field in the ParrotString struct.
> 
> In Haskell I use:
> 
> peekCString =<< #{peek STRING, strstart} s5

Actually, never mind; string_to_cstring is the way to go.

Thanks,
/Autrijus/


pgp12yaLLiRo8.pgp
Description: PGP signature


Re: Parrot as an extension language

2005-05-20 Thread Autrijus Tang
On Sat, May 21, 2005 at 12:53:15AM +0800, Autrijus Tang wrote:
> On Fri, May 20, 2005 at 05:42:48PM +0100, Colin Paul Adams wrote:
> > There is a function declaration
> > Parrot_string_cstring
> > 
> > in string_funcs.h, but it appears to have no definitoon anywhere, so
> > that's not much use to me.
> 
> Yeah, I bumped against that too.  You need to look at the "strstart"
> field in the ParrotString struct.

Coming to think about it, we should either implement
Parrot_string_cstring or take it away from the includes.

I've checked in a naÃve implementation as r8135.

Thanks,
/Autrijus/


pgpIb6KhvkQlI.pgp
Description: PGP signature


Re: Parrot as an extension language

2005-05-20 Thread Autrijus Tang
On Fri, May 20, 2005 at 05:42:48PM +0100, Colin Paul Adams wrote:
> The problem I'm finding with this, is getting back the returned string
> characters.
> I assume the void * returned is pointing to a Parrot String.
> Certainly it's not a const char *.

Yes.

> There is a function declaration
> Parrot_string_cstring
> 
> in string_funcs.h, but it appears to have no definitoon anywhere, so
> that's not much use to me.

Yeah, I bumped against that too.  You need to look at the "strstart"
field in the ParrotString struct.

In Haskell I use:

peekCString =<< #{peek STRING, strstart} s5

Thanks,
/Autrijus/


pgpMz9OMhmo3z.pgp
Description: PGP signature


Re: wanted: hash stress tests

2005-05-20 Thread Leopold Toetsch
Leopold Toetsch wrote:
I'm currently rewriting the hash implementation in src/hash.c. The new 
hash structure has just one piece of malloced memory with bucket 
pointers and buckets in one piece.

But before comitting I'd like to have some stress and benchmarks tests 
that first show that my implementation is correct and of course that 
it's faster too ;-)

I'll ci what I have so far as src/new_hash.c first, when it's usable.
It's in SVN now - rev 8134
please have a look at it,
thanks
leo


Re: wanted: hash stress tests

2005-05-20 Thread Uri Guttman
> "LT" == Leopold Toetsch <[EMAIL PROTECTED]> writes:

  LT> I'm currently rewriting the hash implementation in src/hash.c. The
  LT> new hash structure has just one piece of malloced memory with
  LT> bucket pointers and buckets in one piece.

here is an odd thought to add to that. since your hash is a single hunk
of ram, you could use offsets inside it instead of pointers. that means
it could be both shareable (given locks) and even writable to disk. but
that doesn't handle the issues with serializing the scalar values (and
even keys) but it does make those things easier. and yes i know there is
a core serializer but if you make the hash pointers inside that ram
chunk into offsets instead, that will speed up serializing hashes.

PL/I has a thing called AREA where you could declare one and allocate
anything from it. but all the pointers you got back were offsets from
the base of that area. it was meant just for the ability to create
binary structures in ram that could be written/read to disk and back.

just reminiscing,

uri

-- 
Uri Guttman  --  [EMAIL PROTECTED]   http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs    http://jobs.perl.org


Re: Parrot as an extension language

2005-05-20 Thread Colin Paul Adams
> "Autrijus" == Autrijus Tang <[EMAIL PROTECTED]> writes:

Autrijus> You may wish to use Parrot_call_sub's "SS" form, where
Autrijus> you pass in a string and get back a string.  Something
Autrijus> like this:

Autrijus> my $interp = Parrot_new(undef);

Autrijus> # ... load a .pir file or some other code into
Autrijus> $interp ...

Autrijus> my $code_pmc = Parrot_find_global( $interp,
Autrijus> const_string("Namespace"), const_string("sub_name"), );

Autrijus> my $return_str = Parrot_call_sub( $interp,
Autrijus> $code_pmc, const_string("SS"),
Autrijus> const_string("Your_input_string_here"), );

The problem I'm finding with this, is getting back the returned string
characters.
I assume the void * returned is pointing to a Parrot String.
Certainly it's not a const char *.

There is a function declaration

Parrot_string_cstring

in string_funcs.h, but it appears to have no definitoon anywhere, so
that's not much use to me.
-- 
Colin Adams
Preston Lancashire


Re: reduce metaoperator on an empty list

2005-05-20 Thread Mark A. Biggar
John Macdonald wrote:
Is there a built-in operator that doesn't have a meaningful
identity value?  I first thought of exponentiation, but it has
an identity value of 1 - you just have to realize that since
it is a right associative operator, the identity has to be
applied from the right.
Well the identity of % is +inf (also right side only).  The identities 
for ~| and ~^ are infinitely long bitstrings of 0's, while that for ~& 
is a similarly long bitstring of 1's.  The chained comparison ops are 
weird as depending of which why you define the associativity (and thus 
which side's value you return when true) you get either a left side only 
or right side only Identity.  E.g. if X

--
[EMAIL PROTECTED]
[EMAIL PROTECTED]


Re: How to compile to PIR or byte codes

2005-05-20 Thread Autrijus Tang
On Fri, May 20, 2005 at 03:13:52PM +0100, Colin Paul Adams wrote:
> I am trying to work out how to compile a perl script using pugs.
> (Am I on the right mailing list?)

Well, yes and no.  To run Perl 5 in Parrot, you want the ponie-dev
mailing list -- this is perl6-compiler after all. :-)

> If I do pugs -h, then it suggests to me the -C option will do the
> trick, but does not say what value the backend might be.

Thanks, the latest trunk now suggests ays:

-Cbackendcompile using the compiler backend
(valid backends are: Pugs, Parrot, Haskell

> so it seems to dislike the for, but I guess it's something that comes
> before that. Is there a list of incompatibilites with perl 5 anywhere?
> (I might add that I know very little at all about perl).

The short answer is that Perl6->Parrot codegen is currently very
primitive in Pugs; I expect to improve it next month with Leo and Chip,
but currently it's not robust at all.

However, for some (minimal) success in embedding Perl 6 via Parrot, see
mod_parrot, which has a mod_pugs layer:

http://www.smashing.org/mod_parrot/

The long answer is that, in general, Perl 5 script will not run as Perl 6
without some conversion.  The definitive documents about Perl 6 is the
Synopses:

http://dev.perl.org/perl6/

There are various quick-references in the Pugs tree, assuming you know
some Perl 5:

http://svn.openfoundry.org/pugs/docs/quickref/

There is also a Perl 5 to Perl 6 "porting guide":

http://perlmonks.org/index.pl?node_id=442402

Larry is working on a translator that can compile Perl 5 program into
Perl 6, known as PPD, but it's not released yet.  Nicholas Clark is heading
an effort to run Perl 5 on top of Parrot VM, known as Ponie:

http://poniecode.org/

Thanks,
/Autrijus/


pgpcTFd8xi54H.pgp
Description: PGP signature


Experimental Coroutine support landed.

2005-05-20 Thread Autrijus Tang
A highly experimental implementation of coroutines has landed to Pugs.

The `coro` keyword denotes a coroutine.  It may appear at any place
where `sub` may appear, i.e. in both named and anonymous forms.

I borrowed the semantics from Coro::Cont on CPAN, with the following
restriction that you cannot return() from a coroutine, or yield()
from a non-coroutine.

Tests for coro should go to t/unspecced/, as one of the "speculative"
features.  Use it like this:

coro flip_flop { yield 1; yield 0 }
print flip_flop() while 1; # 1010101010

As you can see, there is an implicit loop around coro's body.
state() and my() variables work as you would expect -- the former
stays in place, while the latter are regenerated when control falls
out from the block and reenters from the top.

Here is another example, courtesy of integral:

my @generators = map -> $N { coro { yield $_ for 0..$N } } 0..9;
say "{ map { $_() }, @generators }" for 0..9;

The above prints:

0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 1 1
0 0 2 2 2 2 2 2 2 2
0 1 0 3 3 3 3 3 3 3
0 0 1 0 4 4 4 4 4 4
0 1 2 1 0 5 5 5 5 5
0 0 0 2 1 0 6 6 6 6
0 1 1 3 2 1 0 7 7 7
0 0 2 0 3 2 1 0 8 8
0 1 0 1 4 3 2 1 0 9

Please direct syntax-related questions and suggestions to p6l as separate
threads; I'd be happy to change the implementation in other ways as
specified by @Larry.

Thanks,
/Autrijus/


pgpIZMrkSGnzS.pgp
Description: PGP signature


Re: reduce metaoperator on an empty list

2005-05-20 Thread TSa (Thomas Sandlaß)
John Macdonald wrote:
... (and there may be additional
operator attributes that make sense there too, although none
come immediately to mind).
Well, I wonder why people neglect the fact that the neutral/identity
element is not a property of the operator alone?! Besides the
associativity and commutativity of the operator the inverse
element---or the left and right one---with respect to the
underlying representation come at least to my mind :)
This would give an "axiomatic" type system:
class Num does Group[Num,+,0] {...}
class Num does Field[Num,+,0,*,1] {...}
class Str does Monoid[Str,~,''] {...}
class Complex does Field[Array[2] of Num,+,[0,0],*,[1,0]] {...}
class 3DVector does VectorSpace[Array[3] of Num,+,[0,0,0]] {...}
And it provides valuable information to the optimizer.
--
TSa (Thomas Sandlaß)


Re: r8118: MSWin32 Test Results

2005-05-20 Thread jerry gay
On 5/20/05, Ron Blaschke <[EMAIL PROTECTED]> wrote:
> 
> t/pmc/bigint now passes, but with Rev 8133 there are several other
> failures (even with a fresh checkout).
> 
> Failed Test Stat Wstat Total Fail  Failed  List of Failed
> ---
> imcc\t\reg\spill.t 1   256 91  11.11%  5
> imcc\t\syn\objects.t  11  281611   11 100.00%  1-11
> imcc\t\syn\tail.t  1   256 61  16.67%  6
> t\dynclass\foo.t   3   768 33 100.00%  1-3
> t\dynclass\gdbmhash.t 13  332813   13 100.00%  1-13
> t\dynclass\pybuiltin.t 6  1536 66 100.00%  1-6
> t\dynclass\pyclass.t   6  1536 66 100.00%  1-6
> t\dynclass\pycomplex.t 2   512 22 100.00%  1-2
> t\dynclass\pyfunc.t4  1024 44 100.00%  1-4
> t\dynclass\pyint.t26  665626   26 100.00%  1-26
> t\library\dumper.t26  665626   26 100.00%  1-26
> t\library\getopt_long.t1   256 11 100.00%  1
> t\library\pcre.t 255 65280 12 200.00%  1
> t\library\pge.t3   768 33 100.00%  1-3
> t\library\streams.t   20  512020   20 100.00%  1-20
> t\op\gc.t  4  1024194  21.05%  10-11 14 19
> t\op\spawnw.t  5  1280 65  83.33%  2-6
> t\op\string.t  1   256   1551   0.65%  140
> t\pmc\exception.t  1   256301   3.33%  21
> t\pmc\freeze.t 8  2048268  30.77%  17-24
> t\pmc\mmd.t8  2048258  32.00%  9 12-16 23-24
> t\pmc\object-meths.t  25  640028   25  89.29%  1-15 17-20 22-26 28
> t\pmc\objects.t   52 1331262   52  83.87%  1-4 8-15 17-37 40-44 
> 46-
>   52 54-56 58 60-62
> t\pmc\threads.t1   256111   9.09%  4
> 2 tests and 63 subtests skipped.
> Failed 24/151 test scripts, 84.11% okay. 229/2483 subtests failed, 90.78% 
> okay.
> 
> The error message usually goes like this.
> 
> ...
> #  got: 'Can't spawn ".\parrot.exe -b --gc-debug "t\op\gc_10.pasm"":
> Bad file descriptor at lib/Parrot/Test.pm line 230.
> ...
> 
> To Be Continued...
> 
> Ron
> 
> 
> 

these have been failing for me since ~r8122. i haven't had time to
investigate further.
~jerry


Re: reduce metaoperator on an empty list

2005-05-20 Thread John Macdonald
On Fri, May 20, 2005 at 06:09:55AM -0700, Randal L. Schwartz wrote:
> > "Mark" == Mark A Biggar <[EMAIL PROTECTED]> writes:
> 
> Mark> The usual definition of reduce in most languages that support it, is
> Mark> that reduce over the empty list produces the Identity value for the
> Mark> operation.
> 
> In Smalltalk, the equivalent of "reduce" is "inject:into:", so a
> "sum" reduce looks like:
> 
>   sum := aList inject: 0 into: [:previous :this | previous + this]
> 
> Now the advantage here is that if aList is empty, we get back the inject
> value.  Thus, the behavior is always well-defined.
> 
> The Perl reduce operator treats the first element of the list as the
> "inject" value above.  However, if the first element is missing,
> the most Perlish thing I can think of is having it return undef,
> because it's like you've specified an undef inject value.

I think we should provide built-in operators with an attribute
called "identity".  Reduce, when given an empty list, would
check if the operator has a defined identity attribute.  If so,
it is returned as the result of the reduction.  If the opereator
has no identity attribute, reduce throws an exception for an
empty list.

Is there a built-in operator that doesn't have a meaningful
identity value?  I first thought of exponentiation, but it has
an identity value of 1 - you just have to realize that since
it is a right associative operator, the identity has to be
applied from the right.

I suspect that if people ever get into writing code that works
on operators instead of data, there would be additional uses
found for the identity attribute (and there may be additional
operator attributes that make sense there too, although none
come immediately to mind).  MJD will soon have to start working
on the second edition of Higher Order Perl.

-- 


How to compile to PIR or byte codes

2005-05-20 Thread Colin Paul Adams
I am trying to work out how to compile a perl script using pugs.
(Am I on the right mailing list?)

If I do pugs -h, then it suggests to me the -C option will do the
trick, but does not say what value the backend might be.

But I'm also having trouble running the script. It runs OK with perl
5, but pugs complains:

*** Error:
unexpected "f"
expecting ";" or "}" at string_value.p6 line 5, column 5

The script is:

#!/usr/bin/perl
sub test {
return unless defined wantarray;  # void context, do nothing
my @parms = @_;
for (@parms) { tr/a-z/A-Z/ }
return wantarray ? @parms : $parms[0];
}

print test ("ok")


so it seems to dislike the for, but I guess it's something that comes
before that. Is there a list of incompatibilites with perl 5 anywhere?
(I might add that I know very little at all about perl).
-- 
Colin Adams
Preston Lancashire


wanted: hash stress tests

2005-05-20 Thread Leopold Toetsch
I'm currently rewriting the hash implementation in src/hash.c. The new 
hash structure has just one piece of malloced memory with bucket 
pointers and buckets in one piece.

But before comitting I'd like to have some stress and benchmarks tests 
that first show that my implementation is correct and of course that 
it's faster too ;-)

I'll ci what I have so far as src/new_hash.c first, when it's usable.
Thanks,
leo


Re: reduce metaoperator on an empty list

2005-05-20 Thread Randal L. Schwartz
> "Randal" == Randal L Schwartz  writes:

Randal> For example, if I wanted the identity hash (where all values are 1,
Randal> but keys are original list elements), I could do:

Randal> my %hash = @somelist.inject({}, { $^a{$^b} = 1; $^a });

And yes, I know I can spell this as:

my %hash = ({}, @somelist).reduce({ $^a{$^b} = 1; $^a });

But it puts things all in the wrong place for me. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
 http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


Re: reduce metaoperator on an empty list

2005-05-20 Thread Randal L. Schwartz
> "Mark" == Mark A Biggar <[EMAIL PROTECTED]> writes:

Mark> The usual definition of reduce in most languages that support it, is
Mark> that reduce over the empty list produces the Identity value for the
Mark> operation.

In Smalltalk, the equivalent of "reduce" is "inject:into:", so a
"sum" reduce looks like:

  sum := aList inject: 0 into: [:previous :this | previous + this]

Now the advantage here is that if aList is empty, we get back the inject
value.  Thus, the behavior is always well-defined.

The Perl reduce operator treats the first element of the list as the
"inject" value above.  However, if the first element is missing,
the most Perlish thing I can think of is having it return undef,
because it's like you've specified an undef inject value.

I'd also argue that we could provide .inject_into, to make Smalltalkers
happy to always spell out the initial value and codeblock, instead
of relying on the first element of the list for the initial value.

For example, if I wanted the identity hash (where all values are 1,
but keys are original list elements), I could do:

my %hash = @somelist.inject({}, { $^a{$^b} = 1; $^a });

That'd be Way Cool.  Once you get your head around inject, you never
want to go back to reduce. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
 http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


Re: r8118: MSWin32 Test Results

2005-05-20 Thread Ron Blaschke
Leopold Toetsch wrote:
> Ron Blaschke wrote:
>> Ron Blaschke wrote:

>t\pmc\bigint.t1   256221   4.55%  22

>> The problem seems to be caused by the C in
>> F.  Well, not the actual cause, but that's
>> where we fail.

> mpz_get_str() returned a string that was very likely allocated by a 
> different "default allocation function".

> This is now changed (rev 8129) by first querying the required string
> length and using Parrot's allocation function so that the free should be
> ok now.

Thought about that too, but then checked the allocation/deallocation
functions, which are simple wrappers around C and C, and
stopped there.

What really bothers me is that the behaviour changed with CPU load.
The expected output is print with high CPU load, but not with low, and
can be reproduced.  I have this weird feeling I usually only get with
uninitialzed writes and data race conditions lurking behind my back.

t/pmc/bigint now passes, but with Rev 8133 there are several other
failures (even with a fresh checkout).

Failed Test Stat Wstat Total Fail  Failed  List of Failed
---
imcc\t\reg\spill.t 1   256 91  11.11%  5
imcc\t\syn\objects.t  11  281611   11 100.00%  1-11
imcc\t\syn\tail.t  1   256 61  16.67%  6
t\dynclass\foo.t   3   768 33 100.00%  1-3
t\dynclass\gdbmhash.t 13  332813   13 100.00%  1-13
t\dynclass\pybuiltin.t 6  1536 66 100.00%  1-6
t\dynclass\pyclass.t   6  1536 66 100.00%  1-6
t\dynclass\pycomplex.t 2   512 22 100.00%  1-2
t\dynclass\pyfunc.t4  1024 44 100.00%  1-4
t\dynclass\pyint.t26  665626   26 100.00%  1-26
t\library\dumper.t26  665626   26 100.00%  1-26
t\library\getopt_long.t1   256 11 100.00%  1
t\library\pcre.t 255 65280 12 200.00%  1
t\library\pge.t3   768 33 100.00%  1-3
t\library\streams.t   20  512020   20 100.00%  1-20
t\op\gc.t  4  1024194  21.05%  10-11 14 19
t\op\spawnw.t  5  1280 65  83.33%  2-6
t\op\string.t  1   256   1551   0.65%  140
t\pmc\exception.t  1   256301   3.33%  21
t\pmc\freeze.t 8  2048268  30.77%  17-24
t\pmc\mmd.t8  2048258  32.00%  9 12-16 23-24
t\pmc\object-meths.t  25  640028   25  89.29%  1-15 17-20 22-26 28
t\pmc\objects.t   52 1331262   52  83.87%  1-4 8-15 17-37 40-44 46-
   52 54-56 58 60-62
t\pmc\threads.t1   256111   9.09%  4
2 tests and 63 subtests skipped.
Failed 24/151 test scripts, 84.11% okay. 229/2483 subtests failed, 90.78% okay.

The error message usually goes like this.

...
#  got: 'Can't spawn ".\parrot.exe -b --gc-debug "t\op\gc_10.pasm"":
Bad file descriptor at lib/Parrot/Test.pm line 230.
...

To Be Continued...

Ron




Re: Parrot as an extension language

2005-05-20 Thread Colin Paul Adams
> "Leopold" == Leopold Toetsch <[EMAIL PROTECTED]> writes:

Leopold> Colin Paul Adams <[EMAIL PROTECTED]> wrote:
>> I have a problem with this - namely that the function is
>> variadic, and the interface generator can't cope with this.

Leopold> Have a look at src/inter_run.c e.g.

Leopold>  interpreter, PMC *sub, const char *sig, va_list args)>

That sounds like just the thing!
-- 
Colin Adams
Preston Lancashire


Re: Parrot as an extension language

2005-05-20 Thread Colin Paul Adams
> "Autrijus" == Autrijus Tang <[EMAIL PROTECTED]> writes:

Autrijus> On Fri, May 20, 2005 at 10:34:39AM +0100, Colin Paul
Autrijus> Adams wrote:
>> I have a problem with this - namely that the function is
>> variadic, and the interface generator can't cope with this.

Autrijus> Hmm, in Haskell FFI, we hard-coded two cases of
Autrijus> invocation, treating the function as two distinct,
Autrijus> non-variadic forms:

Autrijus> -- From
Autrijus> http://svn.openfoundry.org/pugs/src/Pugs/Embed/Parrot.hsc

Autrijus> -- This is the (() returns Void) form foreign import
Autrijus> ccall "Parrot_call_sub" parrot_call_sub_vv ::
Autrijus> ParrotInterp -> ParrotPMC -> CString -> IO ()

Autrijus> -- This is the ((String, String) returns String)
Autrijus> form foreign import ccall "Parrot_call_sub"
Autrijus> parrot_call_sub_SSS :: ParrotInterp -> ParrotPMC ->
Autrijus> CString -> ParrotString -> ParrotString -> IO
Autrijus> ParrotString

Autrijus> Surely you can do the same with Eiffel?

Yes, I can, but that only copes with a single string parameter - there
are very many possibilities (strictly, infinite, though obviously not
in practice).
Also, I shall want to use the object/method calls, which adds further
to the burden.

And I'm not just coding this for my XSLT processor - I am going to
make the Eiffel library freely available to all Eiffel programmers.
That way, any Eiffel program can use any Parrot-targetted scripting
language as an extension language (and the language can be chosen by
the user of the application who wants to do the scripting, not imposed
by the developer of the application).
So this requires a lot of flexibility.

I can easily code by hand (and will, for now) just those subroutines
and methods I shall require for use within my XSLT processor, but to
do them all in general will be too much (so I shall have to request
each application deleoper to add the code necessary that they want).

And this applies to anyone else who wants to use Parrot as a
multi-lingual extension mechanism for another language.
-- 
Colin Adams
Preston Lancashire


Re: [perl #35892] [PATCH] Updated submissions.pod

2005-05-20 Thread Leopold Toetsch
Dino Morelli <[EMAIL PROTECTED]> wrote:

> Updated the How To Submit Something New section to include patching
> the MANIFEST file.

Thanks, applied.
leo


Re: Parrot as an extension language

2005-05-20 Thread Leopold Toetsch
Colin Paul Adams <[EMAIL PROTECTED]> wrote:

> I have a problem with this - namely that the function is variadic, and
> the interface generator can't cope with this.

Have a look at src/inter_run.c e.g.




leo


Re: Parrot as an extension language

2005-05-20 Thread Autrijus Tang
On Fri, May 20, 2005 at 10:34:39AM +0100, Colin Paul Adams wrote:
> I have a problem with this - namely that the function is variadic, and
> the interface generator can't cope with this.

Hmm, in Haskell FFI, we hard-coded two cases of invocation, treating
the function as two distinct, non-variadic forms:

-- From http://svn.openfoundry.org/pugs/src/Pugs/Embed/Parrot.hsc

-- This is the (() returns Void) form
foreign import ccall "Parrot_call_sub"
parrot_call_sub_vv :: ParrotInterp -> ParrotPMC -> CString -> IO ()

-- This is the ((String, String) returns String) form
foreign import ccall "Parrot_call_sub"
parrot_call_sub_SSS :: ParrotInterp -> ParrotPMC -> CString -> 
ParrotString -> ParrotString -> IO ParrotString

Surely you can do the same with Eiffel?

Thanks,
/Autrijus/


pgpj1ErrUpris.pgp
Description: PGP signature


Re: Parrot as an extension language

2005-05-20 Thread Colin Paul Adams
> "Autrijus" == Autrijus Tang <[EMAIL PROTECTED]> writes:

Autrijus> On Tue, May 17, 2005 at 03:00:14PM +0100, Colin Paul
Autrijus> Adams wrote:
>> But when I look at http://www.parrotcode.org/docs/embed.html, I
>> can see no way of getting information back from the script -
>> not even an exit code. Is there anyway of doing this that I
>> have missed?

Autrijus> You may wish to use Parrot_call_sub's "SS" form, where
Autrijus> you pass in a string and get back a string.  Something
Autrijus> like this:

I have a problem with this - namely that the function is variadic, and
the interface generator can't cope with this.

So I'm going to have to do a lot of hand-coding to get round this
problem.

This is a general problem for interface generators, I believe. Would
it be possible to have more friendly functions in embed.h/c for use by
interface generators? 
(By more friendly, I mean instead of ..., a single argument of some
list or array type.)
-- 
Colin Adams
Preston Lancashire


Re: How do I... create a new meta operator?

2005-05-20 Thread TSa (Thomas Sandlaß)
HaloO Luke,
you wrote:
I wonder how we specify meta
operators that only work on comparators, or only on assignment forms,
or etc. etc. etc.
Well, Perl6 has got first class Code types, hasn't it?
So it's a matter of defining a type hierarchy among the
operators and then you can dispatch on them with MMD or
restrict applicable types for non-invocant params.
Ingo's &infix_circumfix_meta_operator:{'->', '<-'}:(Code,Any,Any:)
could then easily be specialized like
 &infix_circumfix_meta_operator:{'->', '<-'}
  :(Comparator of ::T, T does Compare[T], T does Compare[T] :)
or less specific, of course.
The above said, I hope that the degree to which meta ops are
macro/compiler supported versus how much they lean onto the
type system is favoring the type system. The typical Perl < 6
programmer seems for historical reasons more inclined to think
about this language feature more in terms of combinations of
eval, join and split. E.g. could the macro assistence for »« and []
be restricted to parse their inside as an operator name so that
the programmer doesn't have to use their long name? Or is something
more complicated needed? And if yes, then why?
Regards,
--
TSa (Thomas Sandlaß)


rev 8132: .pragma n_operators (was: unary and infix ops summary and todo)

2005-05-20 Thread Leopold Toetsch
Leopold Toetsch <[EMAIL PROTECTED]> wrote:

> 3) Proposal: PIR syntax enhancement

>.pragma n_operators
>...
>Px = Py + 1
>...
>[EOF]

> Within this pragma (valid inside and until end of file) the shortcuts
> '+', '-', ... should translate to "n_add", "n_sub", ...
> This simplifies the adaption of already existing compiler code and is a
> bit more readable.

Done now.

.pragma n_operators 0   # off
.pragma n_operators 1   # turn it on

WRT include files: the intended behavior is that the state of the
n_operators setting reverts to the state before the file inclusion:

  .pragma n_operators 1
  ...
  .include "foo.imc"

  # n_operators is 1 again

*But* inside the include file the last pragma setting is used. This can
be changed easily by not copying the setting in imcc.l:new_frame().

OTOH we could just demand that include files with code have to set /
reset that pragma to the desired value. It's kind of a documentation how
the semantics of

  a = b + c  # new a PMC or not

actually are inside that file.

After we have found a consensus I'd be glad with some tests additionally
to the one in t/pmc/n_arithmetics.t

Thanks,
leo



[perl #35892] [PATCH] Updated submissions.pod

2005-05-20 Thread via RT
# New Ticket Created by  Dino Morelli 
# Please include the string:  [perl #35892]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/rt3/Ticket/Display.html?id=35892 >


file: docs/submissions.pod

Updated the How To Submit Something New section to include patching
the MANIFEST file. Also, instructions for creating a patch for new .t
scripts which sometimes confuse mailers.

Added the Parrot Bug Summary url to the What Happens Next? section.


-Dino

-- 
 .~.Dino Morelli
 /V\email: [EMAIL PROTECTED]
/( )\   weblog: http://categorically.net/d/blog/
^^-^^   preferred distro: Debian GNU/Linux  http://www.debian.orgIndex: docs/submissions.pod

===

--- docs/submissions.pod(revision 8128)

+++ docs/submissions.pod(working copy)

@@ -131,26 +131,37 @@

 

 =item 1

 

-Create a plain text email.

+Add your new file path(s), relative to F, to the file MANIFEST. Create 
a patch for the MANIFEST file according to the instructions above in B

 

 =item 2

 

-Set the recipient to B I B I B.

+If you have a new test script ending in .t, some mailers may become confused 
and consider it an application/x-troff. One way around this (for *nix users) is 
to diff the file against /dev/null like this:

 

+cd parrot

+diff -u /dev/null newfile.t > newfile.patch

+

 =item 3

 

+Create a plain text email.

+

+=item 4

+

+Set the recipient to B I B I B.

+

+=item 5

+

 Give the message a clear and concise subject.

 

 Prefix it with a C<[NEW]> identifier.

 

-=item 4

+=item 6

 

 The message body should contain an explanation of the purpose of the

 feature you are adding.

 

-=item 5

+=item 7

 

-Attach the file(s).

+Attach the patch for MANIFEST and your new file(s).

 

 Double-check that you've actually done this, because it's easy to

 forget.

@@ -158,7 +169,7 @@

 B paste the content of the new file or files into the body of

 the message.

 

-=item 6

+=item 8

 

 Send the mail.

 

@@ -182,6 +193,8 @@

 L. If you have trouble logging in try username

 C with password C.

 

+A Parrot Bug Summary page is also generated and can be viewed here 
L

+

 A list of all the unresolved patches is at

 L

 



Re: hyperoperators and multi-dimensional datastructures

2005-05-20 Thread Anthony Heading
Uri Guttman wrote:
i can't spit out the syntax but here is the conceptual way i would do
it. we do have multidimensional slices so we could grab each slice
(maybe with zip?) and pass that to [+] and then grab the list of results
back into a array/matrix with one less dimension than the original.
Yup.  I wonder though if that formulation is made simpler by
the notion of iterating a data structure at a given
depth.  It might even be useful for $data{$x}{$y}{$z}[$i] or
similar, where e.g. map() could make a deep copy down to a
certain depth where it then operates elementwise.
so it would be something like this: (very wacko pseudo code):
@in[ * ; 2 ; * ] ==>
map [+] ==>
@out
One limiting thing about this is that the data being 3-dimensional
and the focus on the second dimension are explicit in the syntax:
presumably not possible to reduce a $j dimensional array over
dimension $i in the same way.  Equivalently, the autoindexing described
in Synopsis 9 looks like it enables
do -> $i, $j, $k { @sum[$i, $k] = @data[$i, $j, $k] }
which is very elegant.  But if I was wanting to write a library
which handles arbitrary data "cubes", it would be nice to specify
the dimensions using variables.
  LP> I think we're beginning to re-invent PDL.  Poorly.
but is there a p6 pdl yet? they may not need much with multi-dim ops,
slices, hyper and reduce all built in! also with type int (patform
ints), they can get the dense storage needed (but losing any dimensional
flexibility). 
Yes.  I don't quite understand that point. I rather see PDL as a limited 
version of MATLAB, and MATLAB as a limited version of APL.  The right 
set of vector primitives can be combined powerfully in some very 
non-obvious ways (c.f. in fact the recent post by Edward Cherlin), and 
APL and successors have worked this out over 30+ years.  To hold PDL as 
a design benchmark instead doesn't seem quite right.

Rgds
Anthony


foo(1: 2: 3: 4:) ?

2005-05-20 Thread Autrijus Tang
So I'm finally starting to implement multi-level invocants in MMDs.
I'd like to sanity check some cases first, though.

Are these two assumed to be identical?

multi sub foo ($x, $y)
multi sub foo ($x, $y : )

But these two are _not_ identical?

multi sub foo ($x : $y : $z)
multi sub foo ($x : $y : $z : )

Is multiple colons usable in invocation?  If yes, is these two
assumed to be identical?

$a.foo($b : $c);
foo($a : $b : $c);

S12 says all the following cases "come out to the same thing":

$handle.close   # 1
close($handle)  # 2
close $handle:  # 3
close $handle   # 4

Does it mean that during invocation, when there is no colons and
no dots, an implicit colon is added at the end, making all arguments
same-level invocants and subject to MMD?  That is, these are identical:

foo($a, $b)
foo($a, $b : )

But these two are _not_:

foo($a : $b : $c)
foo($a : $b : $c : )

Thanks,
/Autrijus/


pgp0R2QjGrbrx.pgp
Description: PGP signature