On Tue, May 29, 2007 at 05:29:18PM -0400, Chas Owens wrote:
: 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?

Yes, basically.  * should not be committing to a numeric type (which
Inf is at heart), since we want 'a'..* to work as alphanumeric
"infinity" too.  And while we could maybe fudge that one to respect
Inf, other uses of * require that Whatever be a completely separate,
non-confusable type for multiple dispatch purposes.

: Is Inf the canonical way of spelling the literal "infinity"?

Yes.  It's more or less the IEEE definition of infinity, though we allow
Int to be +/- Inf as well as Num.  However, native int cannot hold Inf,
though native num can, presuming IEEE floaters are supported, which all
modern hardware does.

: I am patching Pugs' x and xx operators to handle infinity now.  The
: behavior after the patch is
: pugs> "a" x 5
: "aaaaa"
: 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?

That's how x would work.  See S03 for a description of how xx works.

Larry

Reply via email to