Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-24 Thread Chas. Owens
On Thu, Apr 24, 2008 at 1:20 AM, Ph. Marek [EMAIL PROTECTED] wrote:
 On Mittwoch, 23. April 2008, Larry Wall wrote:
   On Wed, Apr 23, 2008 at 04:03:01PM +0100, Smylers wrote:
   : The algorithm for increment and decrement on strings sounds really good,
   : however I'm concerned that dealing with all that has made the common
   : case of integer decrement a little less intuitive where the integer
   : happens to be stored in a string, for example in this case:
   :
   :perl -wle '$a = 10; $b = shift; $a--; $b--; print $a $b' 10
   :
   : Perl 5 prints 9 9, but Perl 6 will print 9 09.
  
   On the other hand, 09 has the advantage of still having the numeric
   value 9.  But the converse is not true if the user was expecting a
   string decrement, since decrementing 10 in Perl 5 to get 9 is also
   counterintuitive if you were expecting 09.  So Perl 5 just punts,
   which is the third option.  In any case, there's always something
   to explain to a beginner.  But I think in Perl 6 we're leaning more
   toward preserving information than Perl 5 did.
  But that doesn't really work for loops.

  Imagine (excuse my perl5)
 $a = 100;
 $a-- for(1 .. 40);

  So ($a eq 060)?
  Then you'll have the problem that this gets (or might get) interpreted as
  octal somewhere; if not in perl6 directly (because of different base
  specifications), you're likely to get problems when passing that to other
  programs, eg. via system().
snip

If you are certain to want a number then you either need to say

$a = +(100);

or use +($a) when passing it.
-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.


Re: Nomenclature Question - BEGIN etc.

2008-04-10 Thread Chas. Owens
On Thu, Apr 10, 2008 at 2:16 AM, Mark J. Reed [EMAIL PROTECTED] wrote:
 JMD Consider the words that may be used to introduce a block for a special
  JMD purpose, like
  JMD
  JMD  BEGIN
  JMD  END
  JMD  INIT
  JMD  CATCH
  JMD  etc.
  JMD
  JMD  What do you call those?

  Well, lessee.  The Common Lisp spec calls them situations in the
  definition of (eval-when)...

  JMD They are not even special named blocks because
  JMD that is not the block name (that already means something).

  Now you've lost me.  I was pretty sure that was the block name.  AIUI,
  you can give arbitrary names to any block, and these names function
  the same way (i.e. can be used in flow control statements), but they
  also happen to control when the block is actually evaluated.

  CO  The perldocs call them Five specially named code blocks, The Camel
  CO  names them individually (e.g. BEGIN block).  How about phase blocks?
  CO  They control in what phase of compilation/runtime the code runs in.

  I don't know, phase sounds too specific to me.  Does the catching of
  an exception really bring us into a new phase of execution?  What
  about the LAST time through a loop?  etc.


  --
  Mark J. Reed [EMAIL PROTECTED]


It looks like they already have a name in S04: Closure traits*.

* http://dev.perl.org/perl6/doc/design/syn/S04.html#Closure_traits

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.


Re: Nomenclature Question - BEGIN etc.

2008-04-10 Thread Chas. Owens
On Thu, Apr 10, 2008 at 2:29 AM, Mark J. Reed [EMAIL PROTECTED] wrote:
 On Thu, Apr 10, 2008 at 2:26 AM, Chas. Owens [EMAIL PROTECTED] wrote:
It looks like they already have a name in S04: Closure traits*.
  
* http://dev.perl.org/perl6/doc/design/syn/S04.html#Closure_traits

  I don't know, it seems like any value might happen to both be a
  closure and have traits, which aren't necessarily these particular
  ones...
snip

How about Control Closure then?


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.


Re: Nomenclature Question - BEGIN etc.

2008-04-09 Thread Chas. Owens
On Thu, Apr 10, 2008 at 1:31 AM, John M. Dlugosz
[EMAIL PROTECTED] wrote:
 Consider the words that may be used to introduce a block for a special
 purpose, like

  BEGIN
  END
  INIT
  CATCH
  etc.

  What do you call those?  They are not even special named blocks because
 that is not the block name (that already means something).
snip

The perldocs call them Five specially named code blocks, The Camel
names them individually (e.g. BEGIN block).  How about phase blocks?
They control in what phase of compilation/runtime the code runs in.


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.


Re: Easy question: what is a list comprehension ?

2008-04-05 Thread Chas. Owens
On Sat, Apr 5, 2008 at 3:07 PM, John M. Dlugosz
[EMAIL PROTECTED] wrote:
 What is a list comprehension?  I've seen that term bantered around here.
snip

It is like a list, for loop, and grep all rolled up into one.  Here is
what it looks like in Python:

S = [2*x for x in xrange(100) if x**2  3]


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.


Re: Concerns about {...code...}

2007-12-21 Thread Chas. Owens
On Dec 21, 2007 4:51 PM, Dave Whipp [EMAIL PROTECTED] wrote:
 Larry Wall wrote:

  As for the Q base form, it's not really there so much for end-use,

 For an operator not intended for end use, it has a remarkable low
 Huffman rank...


But since it will be combined with adverbs like

my $str = Q :b :s /Hello $name\n/;

it needs to be short.   Q is just one part of a larger expression that
is meant to be taken as a whole.


Re: Bite-sized Tasks for the Interested (was Re: Standards bearers)

2007-12-13 Thread Chas. Owens
On Dec 13, 2007 4:37 PM, ispyhumanfly [EMAIL PROTECTED] wrote:
 Hello list,

 I've created a group on www.hiveminder.org for Perl6 collaborative
 task tracking and management.  I've done some thinking and I've come up
 with a way in which I would like to maintain this group, its organizers
 and its members.
snip

hiveminder.org doesn't seem to exist, do you mean hiveminder.com?


Re: Bite-sized Tasks for the Interested (was Re: Standards bearers)

2007-12-13 Thread Chas. Owens
On Dec 13, 2007 6:30 PM, ispyhumanfly [EMAIL PROTECTED] wrote:
snip
 This task list is available via an rss feed.  I think this will help
 solve the problem in the way you described.
snip

What is the URL for this feed?


Re: What is the origin of the nickname, Texas quotes?

2007-12-07 Thread Chas. Owens
On Dec 7, 2007 11:50 AM, Larry Wall [EMAIL PROTECTED] wrote:
 On Thu, Dec 06, 2007 at 12:12:36PM -0700, Thom Boyer wrote:
  Larry Wall wrote:
  Good guess, but no.  It comes from the fact that Texas always bragged
  about how they were the largest state in the union, and had the biggest
  everything, including ten-gallon hats.  That was before we added Alaska.
  Now if they pull that stunt we offer to carve Alaska up into 4 states,
  in which case Texas would be the 5th largest.
 
  But Texans still like to think big, and we love 'em all to pieces for it.
  Especially Patrick these days... :)
 
  Larry
 
  So, it's because this is so much bigger than «this», this, or 'this'?
 
  By the way, as a native Texan, I find offensive your claim that Texas*4 
  Alaska. The truth is hurtful enough:
 Texas*2.1787 = Alaska
  I had to carry it out to 4 decimal places so I wouldn't have to round the
  last digit UP.
 
  :-)

 My claim is just that that's how the standard joke goes.  (I suspect
 the 4x probably arises from casual inspection of a mercator projection,
 where Alaska does look four times bigger.  But then, that's the fault
 of Texas for being closer to the equator. :)

 Larry


Like a true Texan* (grin), he skewed the numbers to make Texas look
bigger than it is.  It is between 2.4** and 2.5*** when you include
inland bodies of water, and when you include territorial waters it may
well have a 4 to 1 ratio with Texas (since it is effectively a very
large peninsula and Texas has a relatively small coastline).  I have
placed calls to both Alaska's CGIN and NOAA NOS* and they are
trying to find the area of the two states' territorial waters for
me**.  I was not able to find a Texas resource, but so far it
looks like the NOAA NOS and OCS*** are going to be the best bets
anyways.

* I am resident of Virgina, so I have no axe to grind; I am just
looking for a definitive answer.
** random sites on the Internet
*** wikipedia: 663267/261797 = 2.5335
 Census and Geographic Information Network:
http://almis.labor.state.ak.us/?PAGEID=67SUBID=114
* National Ocean Service: oceanservice.noaa.gov
** Yes, I am anal, insane, and on narcotics (I had my wisdom teeth
extracted this morning)
*** Office of Coast Survey:
http://oceanservice.noaa.gov/programs/cs/welcome.html


Re: Ternary endweight alternative?

2007-06-29 Thread Chas Owens

On 6/29/07, raiph [EMAIL PROTECTED] wrote:
snip

Finally, but very importantly imo, what if there are 3 or more
alternatives?

snip

Use a hash or array (depending on the selecting data).

system((zip win32 linux other, cls clear nuke)$?OS);
system({win32='cls', linux='clear', other='nuke'}$?OS);

Of course, this should actually be abstracted more.  What happens if
there is a fourth platform?

my %command = (
   win32 = {
   clear = 'cls',
   ls= 'dir /b',
   dir   = 'dir',
   },
   linux = {
   clear = 'clear',
   ls= 'ls',
   dir   = 'ls -l',
   }
);

...

system %command{$?OS}clear;


Re: [svn:perl6-synopsis] r14421 - doc/trunk/design/syn

2007-06-22 Thread Chas Owens

On 6/22/07, Mark Overmeer [EMAIL PROTECTED] wrote:
snip

* Jonathan Lang ([EMAIL PROTECTED]) [070622 10:41]:

snip

 Please forgive my ignorance: what does AST stand for?

The Abstract Syntax Tree, the result of the code parser, un-interpreted.

snip

You mean it isn't Andrew S. Tanenbaum?  Well, it would have been a lot
easier to write that parser then.  You wouldn't believe how hard it is
to get a Perl script to output a Dutchman.


Re: Web Module (Was: Perl6 new features)

2007-06-22 Thread Chas Owens

On 6/22/07, chromatic [EMAIL PROTECTED] wrote:

On Thursday 21 June 2007 15:23:38 Smylers wrote:

 Has Larry yet decreed whether Web will be bundled with Perl 6?

I also like to proceed from the assumption that the only core modules should
be those required to install other modules.

-- c



Please, god, no.  Or at least make two distributions: Bare Perl 6 and
Perl 6.  Many companies have a Only Core Perl policy.  They refuse
to install CPAN modules because We don't trust them.  Yeah, it is
stupid, but as a contractor I have limited ability to fight their
ignorance.


Re: Web Module (Was: Perl6 new features)

2007-06-22 Thread Chas Owens

On 6/22/07, jerry gay [EMAIL PROTECTED] wrote:

On 6/22/07, Chas Owens [EMAIL PROTECTED] wrote:
 Most of the time the policy is enacted by lower-case-l lazy sysadmins
 who can't be bothered to type

 perl -MCPAN -e install Foo::Bar

 My normal route around them is to install the module into the home
 directory of the user who is going to run the script, but I have had
 difficulty with this before when it comes time to move to production:
 Where is the code review for that code?.  My answer of where is the
 code review for that (often open source) database install you just
 did? doesn't tend to hold the weight I wish it did.  For some reason
 binary blobs make some types of sysadmins feel all fuzzy and warm
 inside.

so use the parrot back end and compile all the modules to bytecode.
oh, and you can merge the foreign module bytecode with the bytecode
for your application, so it's all one big happy binary file.

in fact, parrot will even provide a way to compile bytecode to a
native executable which contains parrot itself. there, now you've got
a proper binary with *zero* external requirements in the production
environment--it doesn't even need to have parrot installed.

at that point, i'd be surprised if the release engineers or sysadmins
even notice.
~jerry



Good point.  I am still to stuck in the Perl 5 mind set.


Re: Web Module (Was: Perl6 new features)

2007-06-22 Thread Chas Owens

On 6/22/07, chromatic [EMAIL PROTECTED] wrote:

On Friday 22 June 2007 11:07:35 Chas Owens wrote:

 Please, god, no. Or at least make two distributions: Bare Perl 6 and
 Perl 6. Many companies have a Only Core Perl policy. They refuse
 to install CPAN modules because We don't trust them.

I think of this the same way I think of Do not drink even if you mix with
beer labels on bleach bottles.  Stupid people often remove their genes from
the pool.  We should not discourage stupid business practices from doing the
same.

-- c



I still need to earn a paycheck, and I would rather do it with Perl
than with Java.  Fighting my customers stupidity, instead of working
around it, is a good way to stop earning my paycheck. But, as Jerry
pointed out, it will be a lot easier to hide module usage in Perl 6.
Get a code review sign off from people who aren't idiots, compile it
all to bytecode, and hand off the binary file to the schmucks who are
the problem.


Re: [svn:perl6-synopsis] r14421 - doc/trunk/design/syn

2007-06-14 Thread Chas Owens

On 6/14/07, Damian Conway [EMAIL PROTECTED] wrote:
snip

To get the multi-line quote, you'd need:

say :to(END);
=begin POD
blah blah blah
=end POD
END

Damian



Would this work as well?

say :to(END);
\x{3D}begin POD
blah blah blah
\x{3D}end POD
END


Re: 'x' vs. 'xx'

2007-06-03 Thread Chas Owens

On 6/3/07, Jonathan Lang [EMAIL PROTECTED] wrote:

Chas Owens wrote:
 Jonathan Lang wrote:
  Is there any reason why we can't simply define '$a x $n' as being
  shorthand for 'cat($a xx $n)'?  In what way does the former differ
  from the latter, other than the use of a Whatever in place of $n?

 $a x $n is equivalent to join '', $a xx $n, but that isn't an apt
 description of its behavior.  cat($a xx *) is an attempt to provide
 an infinite string since 'a' x Inf would result in memory overflow
 (but the cat trick works since lists are evaluated lazily).

Then it looks to me like 'cat($a xx $n)' is more flexible than join
'', $a xx $n, and would work better as the baseline definition for
'$a x $n'.  Is there any reason to prefer a join-based definition to a
cat-based one?  AFAICT, the only thing that 'join' can do that 'cat'
can't is to provide a delimiter when stitching the component strings
together; in the case of 'x', this feature is (rightfully) not being
used.

--
Jonathan Dataweaver Lang



Okay, maybe my understanding of the cat function is flawed, but I
thought it walked through each array handed to it in a serial fashion
(as opposed to zip which walks the arrays in a parallel fashion).  If
that is the case then (a x 5) ne cat(a xx 5).  The former produces
a scalar string value of five characters and the other produces a list
of one character scalar string values.  My understanding is that the
cat function and the xx operator are being used in  the documentation
to mimic what an _infinite_ string (not a normal string) would look
like.  Since you cannot have an infinite string with the current
implementation of scalars (memory would give out), a list with lazy
evaluation is used; however, you could not just drop cat(a xx *)
into a spot where you you were using a x 5.


Re: 'x' vs. 'xx'

2007-06-03 Thread Chas Owens

On 6/3/07, Jonathan Lang [EMAIL PROTECTED] wrote:

Chas Owens wrote:
 Jonathan Lang wrote:
  Chas Owens wrote:
   Jonathan Lang wrote:
Is there any reason why we can't simply define '$a x $n' as being
shorthand for 'cat($a xx $n)'?  In what way does the former differ
from the latter, other than the use of a Whatever in place of $n?
  
   $a x $n is equivalent to join '', $a xx $n, but that isn't an apt
   description of its behavior.  cat($a xx *) is an attempt to provide
   an infinite string since 'a' x Inf would result in memory overflow
   (but the cat trick works since lists are evaluated lazily).
 
  Then it looks to me like 'cat($a xx $n)' is more flexible than join
  '', $a xx $n, and would work better as the baseline definition for
  '$a x $n'.  Is there any reason to prefer a join-based definition to a
  cat-based one?  AFAICT, the only thing that 'join' can do that 'cat'
  can't is to provide a delimiter when stitching the component strings
  together; in the case of 'x', this feature is (rightfully) not being
  used.

 Okay, maybe my understanding of the cat function is flawed, but I
 thought it walked through each array handed to it in a serial fashion
 (as opposed to zip which walks the arrays in a parallel fashion).

Hmm... true enough.  That was an aspect of the 'cat' function that I
hadn't been aware of.  Rather, what came to mind when I saw the 'cat'
function was the following (from S29): ...a CCat in item context
emulates the CStr interface lazily.

In short, 'cat(a x 5)' effectively _is_ a scalar string value of
five characters - in item context.  And because it emulates the string
interface _lazily_, there's no danger from an infinitely long string.

Again, I was not aware that there _was_ a distinct list context result
for 'cat'; and I'm pretty sure that it was referenced as an
alternative to '$a x *' due to its behavior in scalar context, rather
than its behavior in list context.

So the question is this: is there a problem with 'a' x 5 producing
'a', 'a', 'a', 'a', 'a' in list context, and 'a' in item
context?  Or should it produce the latter in anything but void
context?

--
Jonathan Dataweaver Lang



I am almost certain that the following code is in list context.

pugs my @a = '-' x 5, 'foo', '-' x 5;
pugs @a
(-, foo, -)
pugs my @b = cat('-' xx 5), 'foo', cat('-' xx 5)
(-, -, -, -, -, foo, -, -, -, -, -)

However, it does seem that Pug's version of cat does not handle the
Str emulation, so that may fix it, but I don't see how it could since
(at least in my mind) the code above is in list context.


Re: 'x' vs. 'xx'

2007-06-03 Thread Chas Owens

On 6/3/07, Jonathan Lang [EMAIL PROTECTED] wrote:
snip

From what you're saying, I get the impression that you think that '-'
x 5 ought to produce a single string of five dashes regardless of
whether the context is item or list.  Correct?  (Note: I'm not asking
about what the spec says, since what it says is potentially up for
revision, given sufficient cause; I'm asking about what you think the
spec _should_ say.)  If so, cat($n xx *) is not an adequate
replacement for $n x *, since it produces a list of one-character
strings if used in list context.  OTOH, ~cat($n xx *) might work.

snip

The current Perl 5 behavior is

[EMAIL PROTECTED]:~$ perl -le 'my @a = (- x 5, foo, - x 5); print @a'
- foo -
[EMAIL PROTECTED]:~$ perl -le 'my @a = ((-) x 5, foo, (-) x 5); print 
@a'
- - - - - foo - - - - -

I am against anything other than that for x or xx without a really
compelling reason.

snip


Personally, I would tend to favor the notion that infix:x always
produces a single string.  With this in mind, I'm now leaning toward
~cat($a xx $n) as the more verbose equivalent of $a x $n.  You
always produce a single string, and you do so lazily (according to the
way that 'cat' works in item context).

--
Jonathan Dataweaver Lang


I assume it is a bug in Pugs implementation of cat, but
pugs ~cat('a' xx 5)
a a a a a

I also am having a hard time figuring out why I would want an infinite
string.  My first thought was something like

my $ten_zeros = substr(cat(0 xx *), 0, 10);

but that is more clearly written as

my $ten_zeros = 0 x 10;


Re: 'x' vs. 'xx'

2007-06-02 Thread Chas Owens

On 6/2/07, Jonathan Lang [EMAIL PROTECTED] wrote:

Is there any reason why we can't simply define '$a x $n' as being
shorthand for 'cat($a xx $n)'?  In what way does the former differ
from the latter, other than the use of a Whatever in place of $n?

--
Jonathan Dataweaver Lang


$a x $n is equivalent to join '', $a xx $n, but that isn't an apt
description of its behavior.  cat($a xx *) is an attempt to provide
an infinite string since 'a' x Inf would result in memory overflow
(but the cat trick works since lists are evaluated lazily).


Re: propose renaming Hash to Dict

2007-06-01 Thread Chas Owens

On 6/1/07, Doug McNutt [EMAIL PROTECTED] wrote:

At 09:15 -0700 6/1/07, Larry Wall wrote:
: To conclude, as hash definitely tastes better than a dictionary, we
: should stick to that name. ;)
:
: At least nobody can say that Perl is bad taste!

Then maybe we should rename Array to Skewer or Kabob or some such...

Hmm, except it's hard to random access the middle...

Maybe AntsOnALog...  (celery, cream cheese/peanut butter, and raisins)

Since Larry started it:

Don't forget that a common form of hash as a food is SPAM in all capitals. 
Perhaps perl6 could get special dispensation from Hormel.

--

-- From the U S of A, the only socialist country that refuses to admit it. --



That is just not kosher.


Re: propose renaming Hash to Dict

2007-05-31 Thread Chas Owens

On 5/31/07, Darren Duncan [EMAIL PROTECTED] wrote:

Barring some better name, I highly recommend/propose renaming Hash to Dict.


And lets rename Perl to Python. This is just change for the sake of change.

snip

The term Dict (as a short form of dictionary) is well understood by
general people and is the term used for associative arrays in some
other languages, so it is easy to learn, and easy to explain to
people in Learning Perl.

snip

Dict also makes it sound like you are talking about pornography.  Of
course, hash makes it sound like you are talking about getting high.

snip

The term Dict is easier for new people to Perl, either new
programmers or visitors from other languages, to learn than Hash is.
It allows more self-documenting code where one is used.  And writing
Learning Perl should be easier.

snip

Please provide the peer-reviewed study that proves this as it goes
against my experience.

snip

For Perl 5 people, it should be very easy to adapt, or for the most
part they may not notice any difference save for documentation
references.

snip

The Perl 5 people are already annoyed that . is changing to ~, sigils
are becoming invariant, etc.  Why not change the name of one of the
data structures too?  If we give them too many things to complain
about they won't be able to decide where to start!

snip

You also have equal huffmanization since the terms Hash and Dict are
both of the same length, and they are also equally easy to type.

snip

They may be the same number of characters, but I can type hash without
leaving the home row on QWERTY keyboards, I don't know about Dvorak.

snip

And aside from the 4 letter word, all the other details associated
with hashes, eg the % sigil and {} constructor, and parts named
keys,values,pairs,kv et al can/should remain the same as they are.

snip

Right, because dictionaries have keys and values not terms and
definitions.  Of course, it all makes sense now.

snip

In fact, since many users of Perl don't refer to the data type by the
name Hash but rather just by % or {}, the change may not take from
their useability at all or they may not even notice that a change
occurred at all, so easy to adapt.

snip

Except of course those poor schmucks who foolishly wrote code like

if (ref $arg eq 'HASH') { ... }


Re: x, xx, and negative counts

2007-05-29 Thread Chas Owens

On 5/29/07, Mark J. Reed [EMAIL PROTECTED] wrote:

 My expectation before reading the delta was that negative counts
would do a reversal:

123 x -1 = 321

('a', 'b', 'c') xx -3 = ('c', 'b', 'a', 'c', 'b', 'a', 'c', 'b', 'a');

I don't know why I think that makes sense, but it was honestly my
first thought.  Does it make sense to anyone else?  Is there a
compelling reason I'm missing for having negative values behave as if
they were zero rather than adding some other potentially useful
functionality?

snip

In Perl 5 I commonly say things like

sub zeropad (
   my ($len, $s) = @_;
   my $slen = length $s;
   carp the string $s is longer than the specified length $len if
$slen  $len;
   return = 0 x  ($len - length($str)) . $str;
);

Which is roughly equivalent to doing a sprintf with the format %0${len}d.


Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn

2007-05-29 Thread Chas Owens

On 5/29/07, Larry Wall [EMAIL PROTECTED] wrote:

On Tue, May 29, 2007 at 04:05:39PM -0400, Chas Owens wrote:
: On 5/29/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
: snip
: +If the count is less than 1, returns the null string.
: +The count may not be C* because Perl 6 does not support
: +infinite strings.  (At least, not yet...)
: snip
:
: Does may not be c* mean that the compiler should throw a fatal
: error if it sees it or that the program will hang because it is the
: programmer's fault (similar to while 1 {}) .

The compiler is generally allowed to complain about anything it knows
must fail at runtime, and since scalars default to eager, this will
certainly run out of memory at runtime.

Larry



Just an odd corner case, but
   foo x -*
should return an empty string and
   foo xx -*
should return an empty list, right?


Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn

2007-05-29 Thread Chas Owens

On 5/29/07, Larry Wall [EMAIL PROTECTED] wrote:

On Tue, May 29, 2007 at 04:43:20PM -0400, Chas Owens wrote:
: Just an odd corner case, but
:foo x -*
: should return an empty string and
:foo xx -*
: should return an empty list, right?

I'm doubt prefix:-:(Whatever) is defined at all, so that's probably
a run-time failure unless someone defines the appropriate multi.
And if the - fails it never even gets to the x or xx.  The * token
doesn't mean infinity.  It means that the operator you feed it to
has to figure out what it means.  Some operators interpret * to mean
infinity.  But infix:- interprets a * on the left to mean the end
of the current subscript range.  And the range operator interprets *
to mean either negative or positive infinity depending on whether
it's on the left or the right.  We don't require (or even allow)
people to say -*..* as it currently stands.

Larry


Okay, obviously I have more synopsis to read, but currently Pugs says:
pugs my $posinf = *
Inf
pugs my $neginf = -*
-Inf

which made me think * is Inf in scalar context.  Is this a bug in Pugs then?

Is Inf the canonical way of spelling the literal infinity?

I am patching Pugs' x and xx operators to handle infinity now.  The
behavior after the patch is
pugs a x 5
a
pugs a x 0

pugs a x -5

pugs a x Inf
Internal error while running expression:
Infinite replications would exahust memory
pugs a x -Inf


Besides fixing the spelling error on exhaust and making it a real die
instead of an internal error (which I have yet to figure out how to
do), does this match up with your expectations for the replication
operators?


what is the behavior of the x operator (string replication) with negative values

2007-05-25 Thread Chas Owens

In my mind

perl -le 'print join \n, map { [ . 0 x $_ . ] } -1 .. 1'

and

pugs -e 'say join \n, map { [{ 0 x $_}] }, -1 .. 1'

should both print
[]
[]
[0]

But the Pugs code throws
pugs: List.genericTake: negative argument

Is this Pugs specific behavior or has the the x operator changed with
respect to negative values?

from perldoc perlop
  If the right operand is zero or negative, it returns an empty
string . . .