develooper Front page | perl.perl6.language | Postings from April 2006

Re: int context ?

Thread Previous
Larry Wall
April 10, 2006 20:57
Re: int context ?
Message ID:
On Tue, Apr 11, 2006 at 03:49:45AM +0200, herbert breunung wrote:
: hello perlisticers
: (my first post)
: i read in the perl6 book second edition something called
: /Integer context/ and /Numeric context/
: Ican understand the difference but since nowhere in the synopses i read 
: a word abou integer context im not
: shore if these concept is thrown away. is it the case.

Integer context is still specified by int(x()) (or by passing to any
parameter defined as integer), but whether x() can see that context as
distinct from numeric context is open to debate.  It certainly can't
see any context reliably if you go indirect through an assignment:

    my $x = x();	# "whatever" context

: i thought that operations like shifting that can anly aplied to integer 
: may be here in some danger to rethought.

Operations like shifting will naturally coerce to integer if you
hand them a Num, presuming the thing being shifted can be so coerced.
Either that, or the shift operation on a Num just multiplies by some
power of 2, perhaps simply by adding or subtracting from the exponent.
(Except that wouldn't truncate the fractional part immediately like
an integer shift would.  But if you then used it as an integer,
it would truncate it, so maybe that's okay...)


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About