Re: urgent parrot bug / PR opportunity

2005-08-04 Thread Leopold Toetsch

Michal Wallace wrote:


And wouldn't you know it... A bug on the parrot
side cropped up out of nowhere to break them!



==17366== valgrind's libpthread.so: IGNORED call to: pthread_attr_destroy
==17366== Invalid read of size 4
==17366==at 0x43D5123E: Parrot_PyTuple_get_iter (in 
/home/lt/svn/parrot/leo/runtime/parrot/dynext/python_group.so)

==17366==by 0x8115576: Parrot_iter_p_p (ops/experimental.ops:231)

Unfortunately valgrind doesn't show line numbers from the shared lib, 
but PyTuple.get_iter() is short enough so that you should be able to 
track down the problem.


leo



Re: urgent parrot bug / PR opportunity

2005-08-04 Thread Michal Wallace

On Thu, 4 Aug 2005, Leopold Toetsch wrote:


Michal Wallace wrote:


And wouldn't you know it... A bug on the parrot
side cropped up out of nowhere to break them!



==17366== valgrind's libpthread.so: IGNORED call to: pthread_attr_destroy
==17366== Invalid read of size 4
==17366==at 0x43D5123E: Parrot_PyTuple_get_iter (in 
/home/lt/svn/parrot/leo/runtime/parrot/dynext/python_group.so)

==17366==by 0x8115576: Parrot_iter_p_p (ops/experimental.ops:231)

Unfortunately valgrind doesn't show line numbers from the shared lib, but 
PyTuple.get_iter() is short enough so that you should be able to track down 
the problem.


Thanks, Leo!!

I'm afraid this is gibberish to me, but I gave it a shot.

I compared the code for pytuple to pylist and pystring 
and noticed they use the python iterator instead of the 
enum_class one. Also, pylist references in there several

times but it only appears once for pytuple, which can't
change its length. It looks like the other length tests
for pytuple use PMC_int_val instead so I changed that.
Anyway, I have no idea what I'm doing here but it seems
to have fixed the tests. I don't have commit access.

Assuming you don't see anything horribly wrong here, 
would you mind applying this patch?


BTW, the problem is on red hat enterprise linux 3.0 with
a fresh build from subversion)

- Michal
http://withoutane.com/



Index: pytuple.pmc
===
--- pytuple.pmc (revision 8800)
+++ pytuple.pmc (working copy)
@@ -155,12 +155,12 @@
 */

 PMC* get_iter () {
-PMC *iter = pmc_new_init(INTERP, enum_class_Iterator, SELF);
+PMC *iter = pmc_new_init(INTERP, PyBuiltin_PyIter, SELF);
 PMC *key =  pmc_new(INTERP, enum_class_Key);
 PMC_struct_val(iter) = key;
 PObj_get_FLAGS(key) |= KEY_integer_FLAG;
 PMC_int_val(key) = 0;
-if (!((List *) PMC_data(SELF))-length)
+if (!((List *) PMC_int_val(SELF)))
 PMC_int_val(key) = -1;
 return iter;
 }



Re: If topicalization

2005-08-04 Thread TSa (Thomas Sandlaß)

HaloO,

Luke Palmer wrote:

I vaguely recall that we went over this already, but I forgot the
conclusion if we did.


I have a proposal about block owner and block topic pending.
But I guess no one noticed it, ...



In Damian and Larry's talk here at OSCON, I saw the example:

if foo() - $foo {
# use $foo
}

How can that possibly work?  If a bare closure { } is equivalent to -
?$_ is rw { }, then the normal:

if foo() {...}

Turns into:

if foo() - ?$_ is rw { }

And every if topicalizes! I'm sure we don't want that.


I think of - as the binder of the referential environment of the
block/closure that follows. Without it the non block-owning special
form if doesn't touch $_. It just flows into the block from outside.
The other forms like for, while, given, etc. should behave the same.

I would also require an explicit '- $_ is rw' if you want the block
to write to the caller's environment. Perhaps '- :rw' is an abbreviation
for a rw topic. This is the same logic as \:rw for rw ref creation.
I like the very nicely huffmanized rw. It's short if you need/want it.
--
$TSa.greeting := HaloO; # mind the echo!


Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread Andrew Shitov
 I am glad to announce Pugs 6.2.9, released during Ingy's OSCON talk:

 http://pugscode.org/dist/Perl6-Pugs-6.2.9.tar.gz
 SIZE = 1439642
 SHA1 = efd32419dcddba596044a42564936888a28b3c69

 Following last month's plan, this release features a Perl6/PIL to javascript
 code generator, written in Perl 5, currently passing 64% of the test suite.

 We also see the beginning of a code generator from PIL to perl5, and a
 self-representing Perl 6 object model prototype.  The new PIL design and
 runcore is also progressing nicely, which should give a more robust
 specification to Perl 6's compile time and runtime semantics.

 A live CD is available as usual, courtesy of Ingo Blechschmidt:

 http://linide.sf.net/pugs-livecd-6.2.9.iso

 Ingy's slides are under the Pugs tree as
 docs/talks/oscon-apocalypse.spork and
 online at http://www.kwiki.org/apocalypse/start.html in HTML.

 All in all, it's a lot of fun.  Check out the two movies we made for the
 OSCON talk as well:

 http://no.perlcabal.org/~autrijus/oscon05-autrijus.mp4
 http://no.perlcabal.org/~autrijus/oscon05-stevan.mp4

 Change the .mp4 to .swf or .wmv for alternate video formats.
Very simple question:

why do we have to give up a space when calling functions under Pugs?

A need to type open('file.txt') instead of open ('file.txt') makes
me perplexing (not perl-flexing ;-) Our recent discussions in 'zip with()'
gave no answer.

--
___
Andrew, [EMAIL PROTECTED]
___



Re: urgent parrot bug / PR opportunity

2005-08-04 Thread Leopold Toetsch

Michal Wallace wrote:


+PMC *iter = pmc_new_init(INTERP, PyBuiltin_PyIter, SELF);


Done - r8801


-if (!((List *) PMC_data(SELF))-length)
+if (!((List *) PMC_int_val(SELF)))

~

Bogus. Changed to !SELF.elements()

leo



[perl #36808] [PATCH] python_group broken on Win32

2005-08-04 Thread François
# New Ticket Created by  François PERRAD 
# Please include the string:  [perl #36808]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36808 



This patch solves the following link problem :

pystring.o(.text+0x15a): In function `Parrot_PyString_get_repr':
trunk/dynclasses/pystring.pmc:307: undefined reference to 
`Parrot_binary_charset_ptr'
collect2: ld returned 1 exit status
partial link python_group.dll failed (256)

This problem appears with revision 8770.

Francois Perrad.

python.patch
Description: Binary data


Re: Do slurpy parameters auto-flatten arrays?

2005-08-04 Thread TSa (Thomas Sandlaß)

HaloO,

Luke Palmer wrote:

On 8/3/05, Aankhen [EMAIL PROTECTED] wrote:


On 8/3/05, Piers Cawley [EMAIL PROTECTED] wrote:


So how *do* I pass an unflattened array to a function with a slurpy parameter?


Good question.  I would have thought that one of the major gains from
turning arrays and hashes into references in scalar context is the
ability to specify an unflattened array or a hash in a sub call
without any special syntax...


I thought that the obsoletion of special syntax stems from the
type system. Piers seems to have the same view. See his example
of map in his parallel reply.



Well, you can, usually.  This is particularly in the flattening
context.  In most cases, for instance:

sub foo ($a, $b) { say $a }
my @a = (1,2,3);
foo(@a, 3);

Passes the array into $a.  If nothing flattened by default, then you'd
have to say, for example:

map {...} [EMAIL PROTECTED];

And even:

for [EMAIL PROTECTED] - $x {...}

Which I'm not sure people want.  


Ups, I thought the for special form would work as follows.

0. the syntax: for expression block
1. determine (return) type of expression
2. create an iterator for that type
3. Use the iterator until it runs out (is that when it returns undef?)
4. bind the block owner to successive return values of the iterator
   and call the block; if the block is pointy bind its environment as
   well.

With the above

  for @a - $x {...}  # use Iterator of Array

and

  for [EMAIL PROTECTED] - $x {...}  # use Iterator of List

produc the same sequence of values in $x but through different
paths in type space. As long as no user defined types are involved,
I dought they are distinguishable at all.

Here's an idea how a sub becomes its own iterator:

   sub foo() does Iterator[foo]
   {
   random;
   }

   for foo() - $x { say }   # endless loop of random output

How are roles/types composed into Code subtypes?



And the way you pass an array in slurpy context as a single reference
is to backwhack it.  What it comes down to is that either you're
backwhacking things a lot or you're flattening things a lot.  Perl
currently solves it by making the common case the default in each
zone of parameters.


I would be interested to hear arguments to the contrary, however. 


OK, I gave my 0.02.
--
$TSa.greeting := HaloO; # mind the echo!


Re: [perl #36778] [PATCH] gdbmhash with MinGW32

2005-08-04 Thread François PERRAD

At 09:52 03/08/2005 -0700, you wrote:

 [EMAIL PROTECTED] - Mi 03. Aug 2005, 00:40:59]:

 With this small patch, gdbmhash works on MinGW.

Thanks,

the patch is applied, and thinks look OK under Linux as well.

Do you have an explaination why config/auto/gdbm.pl seems to see a gdbm
library. I don't see 'gdbm3' mentioned there. Is the linker in MinGW
smarter than Parrot_load_lib() ?


I use a binary distribution available on http://gnuwin32.sourceforge.net/ 
(v 1.8.3-1)

This distribution contains :
include/gdbm.h
lib/libgdbm.lib (import library used by the linker)
bin/gdbm3.dll   (used at run time)

config/auto/gdbm.pl produces a small executable (so check the availability 
of gdbm.h and libgdbm.lib).

This small executable loads automatically DLL (gdbm3.dll) as usually on Win32.
And I think that parrot loads manually DLL with Parrot_load_lib().

Francois.


CU, Bernhard

--
/* [EMAIL PROTECTED] */





Re: Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread Carl Franks
 why do we have to give up a space when calling functions under Pugs?
 
 A need to type open('file.txt') instead of open ('file.txt') makes
 me perplexing (not perl-flexing ;-) Our recent discussions in 'zip with()'
 gave no answer.

Not sure whether it's enough of an answer, but see:
http://dev.perl.org/perl6/doc/design/syn/S04.html#Statement_parsing

Cheers,
Carl


Re: If topicalization

2005-08-04 Thread Stuart Cook
On 8/4/05, Luke Palmer [EMAIL PROTECTED] wrote:
 How can that possibly work?  If a bare closure { } is equivalent to -
 ?$_ is rw { }, then the normal:
 
 if foo() {...}
 
 Turns into:
 
 if foo() - ?$_ is rw { }
 
 And every if topicalizes! I'm sure we don't want that.
 
 Luke


Here's one solution:

1) Bare blocks don't topicalise if you call them without an argument.

2) 'if' doesn't pass the value of the condition to its body, _UNLESS_
the body is incapable of accepting 0 arguments.


This means:

* The most common case, if foo() { ... }, won't topicalise.

* If you /really/ want to access the value of the conditional, you can
say one of:
if foo() - $_ { ... }# topicalise
if foo() - $cond { ... } # don't topicalise
and 'if' will give it to you.

* The bare-block-to-pointy-sub rewrite rule is preserved, because a
bare block's parameter is optional.

Is there anything I've failed to take into account?


Stuart


Re: [perl #36794] [BUG] substr opcode segfault

2005-08-04 Thread Leopold Toetsch

Will Coleda (via RT) wrote:

causes a segfault in the substr opcode (from tcl's lib/tclconst.pir),  
and forces a few tcl-unicode escape tests into TODOs.


A short PIR test that is equivalent:

.sub main @MAIN
   $S0 = \\u666
   $I0 = 0x666
   $S1 = chr $I0 # works, but substr doesn't like this string.
   substr $S0, 0, 5, $S1
.end


Fixed - r8805

Thanks for testing and providing the test,
leo



Re: zip with ()

2005-08-04 Thread TSa (Thomas Sandlaß)

HaloO,

Luke Palmer wrote:

On 8/1/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote:


In general, (@foo, @bar) returns a new list with the element joined,
i.e. @foo.concat(@bar). If you want to create a list with two sublists,
you've to use ([EMAIL PROTECTED], [EMAIL PROTECTED]) or ([EMAIL PROTECTED], 
[EMAIL PROTECTED]). But of course, I could
be totally wrong. :)



I think that's right.  However, it might be a good idea not to
auto-enreference such bare lists:


I don't like this notion of auto enreference/dereference at all.
Either the type system manages to dispatch things correctly or
you get an error. For the List versus Array problem this dispatch
is IMHO decideable at compile time by strictly typing @ vars as
Array and subtypes thereof. The List type to me is a Code subtype
and as such travels in  vars. I'm only unsure how easily such
variables should enter name space, that is how they behave without
sigil.


sub foo ($x) {...}
foo (1,2,3,4,5);   # foo gets called with [1,2,3,4,5]


Yes, the $x makes foo an Item or even Value taker of arity 1.
The call foo (1,2,3,4,5) OTOH calls it with a List. This should
result in a type error. But sub foo (x) might then work for a List
but not for an Item|Value call foo(1).

Since I think that * in a signature is for extending the arity of
the sub to infinity I wonder if it is possible to capture the caller's
list into a single *$arg?

   sub foo (*$x) {...}
   foo (1,2,3,4,5); # type of $x is now Ref of List of Int?

But with an additional array the slurpy item gets at most one value.

   sub foo (*$x, [EMAIL PROTECTED]) {...}
   foo (1,2,3,4,5); # $x == 1; [EMAIL PROTECTED] == 4
   foo @array; # type of $x is now Ref of Array; @a is undef



When you could just as easily have said:

foo [1,2,3,4,5];

And we'll probably catch a lot of Perl 5 switchers that way.  That
actually makes a lot of sense to me.  The statement:

my $x = (1,2,3,4,5);

Looks like an error more than anything else.


Yep. I opt for type error Can't assign List to Item.
By the same token I would disallow

  my @a = 3; # type error Can't assign Item to Array.

It should be

  my @a = *3;

or

  my @a = (3,);

Hmm, wasn't there a nullary *?

  my @a = *;
  say [EMAIL PROTECTED];  # prints 0



 That's the scalar
comma, which has been specified to return a list.  But maybe it
should be an error.


Sorry, I don't understand this.  I thought comma just is *the*
List constructor per se. Parens required to lift precedence :)
Same applies to semi-colon. (1,2,3;4,5,6) is a List of List of Int.



 The main reason that we've kept a scalar comma is
for:

loop (my $x = 0, my $y = 0; $x*$y = 16; $x++, $y++)
{...}

However, I think we can afford to hack around that.  Make the first
and last arguments to loop take lists and just throw them away.


My interpretation of the loop block controler special form is that
it gets a 4-tupel (Block,Block,Block,Block). The last one is of course
the loop's body. The first is the initializer that is executed in a
scope outside the body. The second and third are the condition and
the stepper and also scoped outside the body.

Now to the comma. It should be parsed as List of Block. In your example
the argument type of loop is (List of Block,Block,List of Block,Block).
The loop instanciates an Iterator[List of Block] and uses it to
execute the Blocks one at a time. The only special case is in the
condition which evaluates only the last Block from the List of Block
for truth and the others in Void context.

Is loop supposed to be a topicalizer? Does it bind the block owner?
Does a pointy body block make sense?

   loop (my $x = 0; $x  10; $x++) - {...}  # current count in $_?
   loop (my $x = 0; $x  10; $x++){...}  # $_ unchanged from outside?

   loop (my $x = 0; $x  10; $x++)
   {
   .blubber   # what is the invocant?
   }

Can the last Block also be separated with semi-colon? I guess not.
How about a Code var?

  loop my $x = 0; $x  10; $x++; say $x;  # works?

  loop my $x = 0; $x  10; $x++; foo; # works?

  loop( my $x = 0; $x  10; $x++; foo ) # perhaps as function call?

  loop
 my $x = 0;
 $x  10;
 $x++;

  say $x; # still the loop body? Or does it need { say $x }?

  loop foo; bar; blubb -
  {
  say  # prints return value of blubb while bar returns true
   # first iteration prints return value of foo
  }


 Can
anyone think of any other common uses of the scalar comma?


Not me. It's a C relict.
--
$TSa.greeting := HaloO; # mind the echo!


Re[2]: Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread Andrew Shitov

 why do we have to give up a space when calling functions under Pugs?

 Not sure whether it's enough of an answer, but see:
 http://dev.perl.org/perl6/doc/design/syn/S04.html#Statement_parsing

it says:

if $term ($x)   # syntax error (two terms in a row)


if this cause an error, why not treat '$term ($x)' as a function call.
At least when $term is not some abstract variable but valid name of simple
function.

--
___
Andrew, [EMAIL PROTECTED]
___



Re: Re[2]: Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread Carl Franks
   why do we have to give up a space when calling functions under Pugs?
 
   Not sure whether it's enough of an answer, but see:
   http://dev.perl.org/perl6/doc/design/syn/S04.html#Statement_parsing
 
 it says:
 
 if $term ($x)   # syntax error (two terms in a row)
 
 if this cause an error, why not treat '$term ($x)' as a function call.
 At least when $term is not some abstract variable but valid name of simple
 function.

(I have nothing to do with the design process, so this is just my take on it)...

I get the impression that driving these sort of decisions, is the
historical problem we've had with only `perl` being able to parse
Perl.
Syntax is getting tightened up a little, with the result that perl6
programs are much more easily read, with the intention of allowing
different compiler implementations.

Also, we can only know if $term contains a valid subroutine name at
runtime, and perl6 aims to allow very separate compilation and runtime
phases (and syntax errors need to be figured out at compilation time).

Carl


Re: Do slurpy parameters auto-flatten arrays?

2005-08-04 Thread TSa (Thomas Sandlaß)

HaloO,

Piers Cawley wrote:

By the way, if flattening that way, what's the prototype for zip? We can after
all do:

   zip @ary1, @ary2, @ary3, ... @aryn


How about

   sub zip( List [EMAIL PROTECTED] ) {...}

a slurpy List of Array of List. The return value is a
not yet iterated Code object that knows how to produce
tuples from the outer lists. This implies that zip(@array)
basically returns an unstarted iterator on @array.
--
$TSa.greeting := HaloO; # mind the echo!


Re: Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread Autrijus Tang
On Thu, Aug 04, 2005 at 10:55:12AM +0400, Andrew Shitov wrote:
 why do we have to give up a space when calling functions under Pugs?
 
 A need to type open('file.txt') instead of open ('file.txt') makes
 me perplexing (not perl-flexing ;-) Our recent discussions in 'zip with()'
 gave no answer.

This is so:

print (1+2)*3;

can print 9, instead of 3.

However, all three forms below should still work:

open('file.txt');
open ('file.txt');
open 'file.txt';

Thanks,
/Autrijus/


pgpOUEocut2jd.pgp
Description: PGP signature


Re: Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread Brano Tichý

Thus spake Autrijus:



This is so:

print (1+2)*3;

can print 9, instead of 3.






Just a newbie question: what would

   print (1+2)x3;

print (or do)? And is

   print .(1+2)*3

allowed?

brano tichý



Re: Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread Carl Franks
I've just realised I quoted the wrong doc earlier, I meant to link to:
http://dev.perl.org/perl6/doc/design/syn/S12.html#Methods

.doit ()# ILLEGAL (two terms in a row)
.doit .()   # okay, no arguments, same as .doit()

I had wrongly thought this also applied to subroutine calls, and that
the OP's open ('file.txt'); was illegal. I stand corrected!

Cheers,
Carl


PXPerl 5.8.7-4 released with Windows binaries of Pugs 6.2.9

2005-08-04 Thread Grégoire Péan
Hello,

This time, I made as swift as possible :)

Windows users, save time compiling Pugs 6.2.9 and Parrot 0.2.2,
download PXPerl today!

http://pixigreg.com/?pxperl

See you soon,
Grégoire

-- 
www.pixigreg.com
[EMAIL PROTECTED]


Re: [perl #36808] [PATCH] python_group broken on Win32

2005-08-04 Thread Jonathan Worthington

François PERRAD (via RT) [EMAIL PROTECTED] wrote:


This patch solves the following link problem :

pystring.o(.text+0x15a): In function `Parrot_PyString_get_repr':
trunk/dynclasses/pystring.pmc:307: undefined reference to
`Parrot_binary_charset_ptr'
collect2: ld returned 1 exit status
partial link python_group.dll failed (256)

This problem appears with revision 8770.


Applied (r8807), thanks.

Jonathan 



TSa's Perl 6 type lattice version 1.0

2005-08-04 Thread TSa (Thomas Sandlaß)

HaloO,

in case someone might be interested, here is my more or less complete
idea of the Perl 6 type lattice as ASCII art.

Enjoy. Comments welcome.


::Any
...| ...
   ___:___/|\:_:
  |   :| :  |  |   static type :
   Package:| : Void  ?Bool   = context :
  |   :| :__|__|   :
Module:|/:.:
   ___|___:|
  |   |   :|
Class Grammar :|
  |___|   :|
  |   :|
 Role : Object Record =::= Frame =::= Dictionary
  :|
  : __/ \_
  with:|  || ||   |
  invocant(s) :  Code  $Item%Hash Frame@Array Tuple
  :|  ||_||___|
  block owner : topic  |  |   |
   $/ : $_ |  |   |
  :___/ \_ ___|   |
 |:  |\   |   ||  | |  |  |
  .Method : Sub\  -Block   \Ref Value  Undef  Inf  Junction  |
/|:  |\ \ ||  |
   / |:  | \ \  __||_ |
Rule |:  | Macro  \/  ||   |   | ||
 |:_/|Ref[Code]   |  :Pair  /Match/  ~Str  +Num   |
 |:  |||   | ||
   Multi  :  |||   |Int   |
..:  |||   |   / ||
 ||___  ___|   Enum  ||
 ||   \/ |   ||
 ||  Entry[::T.does(Hash)]  Bit  ||
_|__  |___  _||
   || |   \/  |
   =Iterator  *List   |  Pos[::T.does(Str|Array)] |
| |   |
|_   _|___|
   |  | ||\ / |
..Range  Pipe  Lazy  **Eager  Ref[Array|Hash] |
   |__|_||   _|
  \ /
   (to | all leafes)
  \|/
::All
--
$TSa.greeting := HaloO; # mind the echo!


What's needed for a new languages/t/*?

2005-08-04 Thread Amir Karger
I'm about to commit an updated version of leo's Z-code-to-PIR
translator. I'm wondering what I should do about t.

I have a test script that runs 85 tests (and will run many more once I
write more opcodes. Luckily, I developed it already when I was doing
plotz). I could easily modify it to output ok n and not ok with a
comment about what went wrong.  However, because it's a big Z-code
file, it would be hard to write a Test::Simple script that calls ok()
85 times. In quickly looking at languages/* I saw that there seem to
be a number of different ways of doing tests, some of which use
Parrot::Test.

So if all I want to do is, essentially, perl -e 'chdir languages/Z and
system(parrot z3.imc t/test.z3)' and let the script print out a
bunch of (not )?ok's for Test::Harness to read, what should I do in my
t directory? (Also, how do I make sure it'll find parrot before make
install has been done?) I didn't see a languages.pod with this info,
but maybe I just wasn't looking in the right place.

-Amir Karger


Re: Whitespace (Was: [RELEASE] Pugs 6.2.9 released!)

2005-08-04 Thread H.Merijn Brand
On Thu, 4 Aug 2005 20:21:18 +0800, Autrijus Tang [EMAIL PROTECTED]
wrote:

 On Thu, Aug 04, 2005 at 10:55:12AM +0400, Andrew Shitov wrote:
  why do we have to give up a space when calling functions under Pugs?
  
  A need to type open('file.txt') instead of open ('file.txt') makes
  me perplexing (not perl-flexing ;-) Our recent discussions in 'zip with()'
  gave no answer.
 
 This is so:
 
 print (1+2)*3;
 
 can print 9, instead of 3.

Just out of curiousity, what would

print (1 + 2) * 3;

print?
FWIW I would *expect* print (1+2)*3; to print '3'

 However, all three forms below should still work:
 
 open('file.txt');
 open ('file.txt');
 open 'file.txt';
 
 Thanks,
 /Autrijus/


-- 
H.Merijn BrandAmsterdam Perl Mongers (http://amsterdam.pm.org/)
using Perl 5.6.2, 5.8.0, 5.8.5,  5.9.2  on HP-UX 10.20, 11.00  11.11,
 AIX 4.3  5.2, SuSE 9.2  9.3, and Cygwin. http://www.cmve.net/~merijn
Smoking perl: http://www.test-smoke.org,perl QA: http://qa.perl.org
 reports  to: [EMAIL PROTECTED],perl-qa@perl.org


[perl #36812] Compiling Pugs against Parrot

2005-08-04 Thread via RT
# New Ticket Created by  Lambeck 
# Please include the string:  [perl #36812]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36812 


For the last 2 hours I tried to compile Pugs-2.6.9 against Parrot-0.2.2.
It does not work because Pugs is not able to query the parrot config like 
this:
./parrot parrot-config.imc ldflags

The I get :
error:imcc:No such file or directory
in file 'parrot-config.imc' line 53

Important to mention that I am using the installed version of parrot (make 
install). When I tell pugs to use the tree I compiled from there is no 
problem at all.

I posted here because I think this is a make install issue of parrot but I 
was not able to figure out what to change in order to make pugs compile.
Maybe this is a good opportunity to also fix the bug I reported earlier 
(#34379). I am not able to fix this myself because I am not into the way 
parrot does the install.

Adrian


Reading a large data structure

2005-08-04 Thread Amir Karger
Is there a way to declare an array of, say, 300 strings in PIR other than

arr = 300
arr[0] = hi
arr[1] = there
arr[2] = my
...
arr[298] = very
arr[299] = tired

Same question with a hash of hashes or whatever. 

-Amir


Re: Whitespace

2005-08-04 Thread Andrew Shitov


print (1+2)*3;

can print 9, instead of 3.


I'd prefer always have '3' (as a result of sum 1 + 2) here.
A C-programmer would tread this like

(print (1 + 2) * 3); # prints int, then returns void


print (or do)? And is

   print .(1+2)*3

allowed?


in fact, that is exactly

(print.getArgument(3) * 3); the same as above.

so why not 'print($x)' == 'print ($x)' ;-)

--
Andrew.



Re: zip with ()

2005-08-04 Thread Larry Wall
On Mon, Aug 01, 2005 at 01:13:52PM +0200, TSa (Thomas Sandlaß) wrote:
: BTW, you didn't mean originally:
: 
:   say zip (@odd), (@even); # prints 13572468 or 12345678?

That doesn't work, since () in list context does not enforce scalar context.
It's exactly equivalent to

say zip @odd, @even;

which is also wrong, because zip is requires multidimentional slice
syntax.  Ordinary commas will be taken to separate items of the first
slice.  To separate slices requires semicolon or pipes.

: Does zip now interleave two array refs instead
: of flattened arrays?

No, but separating the arrays with comma doesn't work either, so Pugs
currently has it wrong.  The correct syntax will eventually be:

zip(@odd; @even)
zip @odd == @even

The parens are required only at the top statement level.  Inside other
bracketing structures you can omit the parens:

(zip @odd; @even)

just as in subscripts the semicolon separates multiple dimensions:

@[EMAIL PROTECTED]; @b]

Larry


Re: What's needed for a new languages/t/*?

2005-08-04 Thread Will Coleda
Excellent questions. Perhaps I can whip up a languages.pod once 0.2.3  
is out the door, based on partcl and the current state of a few other  
languages out there.


Right now, the unified language testing harness, such as it is,  
would rather you had a script called harness that took a --files  
option to figure out what .t files to run. The .t files don't have to  
be perl scripts, but it helps: we don't have a lot of requirements  
for parrot at the moment, so for portability perl is the best. (but  
you could make it a shell script, or whatever. Just be careful with  
$Test::Harness::Switches).


Finding parrot before make install is done is somewhat tricky: this  
is another reason to use the builtin Parrot::Test modules. Right now,  
several languages provide a language specific class this can dispatch  
to, e.g. Parrot::Test::Tcl. {{ this implementation is a little  
muddy at the moment and could probably use some cleanup }}


But, for now, if you have a .t script that works, I would say commit  
it (after the code freeze, of course); we can have you be standalone  
for now and integrate you into the unified lang testing later. Many  
of the existing languages are in various states of disrepair in re:  
testing, so it won't be evil.


On Aug 4, 2005, at 8:52 AM, Amir Karger wrote:



I'm about to commit an updated version of leo's Z-code-to-PIR
translator. I'm wondering what I should do about t.

I have a test script that runs 85 tests (and will run many more once I
write more opcodes. Luckily, I developed it already when I was doing
plotz). I could easily modify it to output ok n and not ok with a
comment about what went wrong.  However, because it's a big Z-code
file, it would be hard to write a Test::Simple script that calls ok()
85 times. In quickly looking at languages/* I saw that there seem to
be a number of different ways of doing tests, some of which use
Parrot::Test.

So if all I want to do is, essentially, perl -e 'chdir languages/Z and
system(parrot z3.imc t/test.z3)' and let the script print out a
bunch of (not )?ok's for Test::Harness to read, what should I do in my
t directory? (Also, how do I make sure it'll find parrot before make
install has been done?) I didn't see a languages.pod with this info,
but maybe I just wasn't looking in the right place.

-Amir Karger








Re: [perl #36812] Compiling Pugs against Parrot

2005-08-04 Thread Leopold Toetsch


On Aug 4, 2005, at 16:17, Lambeck (via RT) wrote:



# New Ticket Created by  Lambeck
# Please include the string:  [perl #36812]
# in the subject line of all future correspondence about this issue.
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36812 


For the last 2 hours I tried to compile Pugs-2.6.9 against 
Parrot-0.2.2.
It does not work because Pugs is not able to query the parrot config 
like

this:
./parrot parrot-config.imc ldflags

The I get :
error:imcc:No such file or directory
in file 'parrot-config.imc' line 53


That line does .include iterator.pasm

Important to mention that I am using the installed version of parrot 
(make

install). When I tell pugs to use the tree I compiled from there is no
problem at all.


So the question is: is that file installed properly to your --prefix 
directory structure?
Maybe you are querying the wrong parrot too (the config paths and 
settings gets compiled into the executable of parrot)?


I posted here because I think this is a make install issue of parrot 
but


I'm pretty sure that there are a lot of make install issues - mostly 
missing files I presume. The install target is really experimental for 
now: more just present to check strategies, how it should be done, then 
really useful.



I
was not able to figure out what to change in order to make pugs 
compile.

Maybe this is a good opportunity to also fix the bug I reported earlier
(#34379). I am not able to fix this myself because I am not into the 
way

parrot does the install.


We'll have a closer look after the release.


Adrian


leo



Re: What's needed for a new languages/t/*?

2005-08-04 Thread Bernhard Schmalhofer

Amir Karger schrieb:


I have a test script that runs 85 tests (and will run many more once I
write more opcodes. Luckily, I developed it already when I was doing
plotz). I could easily modify it to output ok n and not ok with a
comment about what went wrong.  However, because it's a big Z-code
file, it would be hard to write a Test::Simple script that calls ok()
85 times. In quickly looking at languages/* I saw that there seem to
be a number of different ways of doing tests, some of which use
Parrot::Test.

So if all I want to do is, essentially, perl -e 'chdir languages/Z and
system(parrot z3.imc t/test.z3)' and let the script print out a
bunch of (not )?ok's for Test::Harness to read, what should I do in my
t directory?


AFAIK there are no strict testing requirements for language implementations.
I think that the most important thing is to try to be nice.

There are three things that I want to suggest:

i. Z/t/z3.t should be a Perl5 script that prints output in Test Anything 
Protcol.

So put your 'system(parrot z3.imc t/test.z3)' into Z/t/z3.t

ii. Z/t/harness should behave like most other 't/harness'. It executes 
the t/*.t files and prints

a harness report of the output.

iii. 'Z/t/harness --files' returns the list of test files.

You could also try to put 'Z' into @unified_testable_languages of 
'languages/testall' and add support for Z in
'config/gen/makefiles/languages.in'. Calling 'make languages-test' could 
then test 'Z' along the other languages.



(Also, how do I make sure it'll find parrot before make
install has been done?) 


I would expect that an install parrot is only found when the
executable 'parrot' is in $PATH.
Before installation I usually use $FindBin::Bin for building up the
relevant paths.


I didn't see a languages.pod with this info,
but maybe I just wasn't looking in the right place.
 

I think there in no such documentation. New insight could be added to 
'docs/compiler_faq.pod'.


CU, Bernhard


Re: Reading a large data structure

2005-08-04 Thread Bernhard Schmalhofer

Amir Karger schrieb:


Is there a way to declare an array of, say, 300 strings in PIR other than

arr = 300
arr[0] = hi
arr[1] = there
arr[2] = my
...
arr[298] = very
arr[299] = tired

Same question with a hash of hashes or whatever. 
 


Assigning an integer to the array should do the trick.

 .local pmc arr
 arr = new ResizablePMCArray
 arr = 300

should allocate storage for at least 300 PMCs.
For Hashes I think there is no such allocation strategy.

CU, Bernhard



Re: Reading a large data structure

2005-08-04 Thread Leopold Toetsch


On Aug 4, 2005, at 14:59, Amir Karger wrote:



Is there a way to declare an array of, say, 300 strings in PIR other 
than


arr = 300
arr[0] = hi
arr[1] = there
arr[2] = my
...
arr[298] = very
arr[299] = tired


Read the array entries from a text file?


-Amir


leo



$pair[0]?

2005-08-04 Thread Ingo Blechschmidt
Hi,

my $pair = (a = 1);
say $pair[0];  # a?
say $pair[1];  # 1?

I've found this in the Pugs testsuite -- is it legal?


--Ingo

-- 
Linux, the choice of a GNU | Black holes result when God divides the
generation on a dual AMD   | universe by zero.  
Athlon!| 



Re: $pair[0]?

2005-08-04 Thread Andrew Shitov
 say $pair[0];  # a?

It looks like $pair is an arrayref while 'say ref $pair' tells 'Pair'.

And may I ask a relating question:

my $pair = ('name' = 'age');
say $pair{'name'}; # prints 'age'
say $pair['name']; # why prints 'name'? == question
say $pair['age']; # prints 'name'


--
___
Andrew, [EMAIL PROTECTED]
___



undef.chars?

2005-08-04 Thread Ingo Blechschmidt
Hi,

(found in the Pugs testsuite.)

my $undef = undef;
say $undef.chars?   # 0? undef? die?
say chars $undef;   # 0? undef? die?

I'd opt for undef.chars to be an error (no such method) and chars
undef to return 0 (with a warning printed to STDERR^W$*ERR).

Opinions?


--Ingo

-- 
Linux, the choice of a GNU | When cryptography is outlawed, bayl bhgynjf
generation on a dual AMD   | jvyy unir cevinpl!  
Athlon!| 



Re: $pair[0]?

2005-08-04 Thread Ingo Blechschmidt
Hi,

Andrew Shitov wrote:
 say $pair[0];  # a?
 
 It looks like $pair is an arrayref while 'say ref $pair' tells 'Pair'.

right, this is why I asked, IMHO it's bogus.

 And may I ask a relating question:
 
 my $pair = ('name' = 'age');
 say $pair{'name'}; # prints 'age'
 say $pair['name']; # why prints 'name'? == question
 say $pair['age']; # prints 'name'

That's probably because both name and age get numified to 0 which in
turn means (in current Pugs) .key.


--Ingo

-- 
Linux, the choice of a GNU | There are no answers, only
generation on a dual AMD   | cross-references.  
Athlon!| 



Re: $pair[0]?

2005-08-04 Thread Luke Palmer
On 8/4/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote:
 Hi,
 
 my $pair = (a = 1);
 say $pair[0];  # a?
 say $pair[1];  # 1?
 
 I've found this in the Pugs testsuite -- is it legal?

Nope.  That's:

say $pair.key;
say $pair.value;

Also:

say $paira;  # 1
say $pair{anything else};   # undef

But we don't implicitly cast references like that.

Luke


Re: Reading a large data structure

2005-08-04 Thread Leopold Toetsch


On Aug 4, 2005, at 22:20, Leopold Toetsch wrote:




On Aug 4, 2005, at 14:59, Amir Karger wrote:


Is there a way to declare an array of, say, 300 strings in PIR other 
than



Read the array entries from a text file?


The more, that it looks like that you are dealing with the string 
abbreviation table, which is very likely Z version dependent.



-Amir


leo



Re: undef.chars?

2005-08-04 Thread Luke Palmer
On 8/4/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote:
 Hi,
 
 (found in the Pugs testsuite.)
 
 my $undef = undef;
 say $undef.chars?   # 0? undef? die?
 say chars $undef;   # 0? undef? die?
 
 I'd opt for undef.chars to be an error (no such method) and chars
 undef to return 0 (with a warning printed to STDERR^W$*ERR).

Well, I think that chars $undef should be exactly equivalent to
$undef.chars.  In fact, I think it is: chars $undef is just the
indirect object form.

So perhaps method not found errors fail instead of die.

Luke


Re: $pair[0]?

2005-08-04 Thread Ingo Blechschmidt
Hi,

Luke Palmer wrote:
 On 8/4/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote:
 my $pair = (a = 1);
 say $pair[0];  # a?
 say $pair[1];  # 1?
 
 I've found this in the Pugs testsuite -- is it legal?
 
 Nope.  That's:
 
 say $pair.key;
 say $pair.value;
 
 Also:
 
 say $paira;  # 1
 say $pair{anything else};   # undef
 
 But we don't implicitly cast references like that.

thanks for clarification, that's what I've thought, too :)


--Ingo

-- 
Linux, the choice of a GNU | The next statement is not true.
generation on a dual AMD   | The previous statement is true.
Athlon!|



Data constructors / Unidirectional unification

2005-08-04 Thread Luke Palmer
I'm writing a new module that optimizes sets of conditions into
decision trees.  Initially I allowed the user to specify conditions as
strings, and if that condition began with a !, it would be the
inverse of the condition without the !.

But then I thought, the user will more than likely have condition
*objects* if the conditions are anything but trivial.  Then you can't
just put a ! on the front.  The way Haskell and ML do this is by
allowing data constructors: symbols that can take arguments and be
pattern matched against.  I thought that this was a particularly
elegant way to solve the problem, so I implemented it in the
Symbol::Opaque module.  Now I want it for Perl 6.

Here's my proposal.  Let's generalize the backtick from unit support
into data constructor support.  The following are equivalent:

4`meters
`meters(4)

The postfix form is only available for single-argument constructors,
but the prefix form can be used with more than one argument:

`foo(4, 5)

These things don't need to be declared, but you can use a data
declaration to give them a type (which does Symbol, the type of all
such constructors):

data Quux (`foo, `bar, `baz);

Now whenever you create a `foo, it is a Quux.  These can overlap:

data Foo (`baz);
data Bar (`baz);

A `baz object is now both a Foo and a Bar.  These could be easily
extended to allow type signatures, to come up with those nice
type-checked data structures that we're using for PIL.  But I'm not
proposing that part yet.

Here's what makes them so useful:  they can be bound against:

sub to_SI (`meters($m)) { `meters($m) }
sub to_SI (`feet($f))   { `meters(feet_to_meters($f)) }

Here's an excerpt from my module (perl6ized):

sub invert ($in) {
my `not($x) := $in ?? $x :: `not($in);
}

Or maybe that's:

sub invert ($in) {
`not(my $x) := $in ?? $x :: `not($in);
}

Anyway, the point is that bindings can fail.  In boolean context, they
return whether they succeed; in void context, they blow up if they
fail (probably fail).

As multimethods:

multi invert (`not($x)) { $x }
multi invert ($x)   { `not($x) }

Which I like the best.

Pairs are values: like numbers.  `foo =:= `foo.  They can just have sub-values.


Re: undef.chars?

2005-08-04 Thread Brent 'Dax' Royal-Gordon
Luke Palmer [EMAIL PROTECTED] wrote:
 On 8/4/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote:
  my $undef = undef;
  say $undef.chars?   # 0? undef? die?
  say chars $undef;   # 0? undef? die?
 
  I'd opt for undef.chars to be an error (no such method) and chars
  undef to return 0 (with a warning printed to STDERR^W$*ERR).
 
 Well, I think that chars $undef should be exactly equivalent to
 $undef.chars.  In fact, I think it is: chars $undef is just the
 indirect object form.

Didn't $Larry rule that method calls on undef return undef, for the
same reason array and hash subscripting does?

-- 
Brent 'Dax' Royal-Gordon [EMAIL PROTECTED]
Perl and Parrot hacker