Re: split on empty string

2006-01-18 Thread Mark Reed
On 2006-01-18 10:04 AM, David K Storrs [EMAIL PROTECTED] wrote:
 Just to show opposite, I've always found that behavior (i.e.
 returning the original string unchanged) confusing.  Csplit works
 based on sequential examination of the target string to locate
 matching substrings on which to split.  There is a matching empty
 string substring between every character.  Naturally, what you get
 back is an array of characters.
 
 Plus, it's a useful idiom.

You misunderstand.  We're not talking about splitting a string with the
empty string as the delimiter.  We're talking about splitting the empty
string (as the target), with any delimiter whatsoever.  If you do that, what
you get back is an empty array.

Perl6 .split(/whatever/) is equivalent to split(/whatever/,) in Perl5.
It's not like the silly Python idiom where the invocant is the delimiter
string. :)

So this is the Perl5 to which I was referring:

   my @result = split(/whatever/, );
   print [EMAIL PROTECTED],\n;# -- 0

The general case I was comparing it to is when the target string is *not*
empty but doesn't match, in which case you get the original string back:

my @result = split(/foo/, bar);
print [EMAIL PROTECTED],\n;# -- 1
print $result[0],\n;   # -- bar





Re: split on empty string

2006-01-17 Thread Mark Reed
On 2006-01-17 12:24 PM, Gaal Yahas [EMAIL PROTECTED] wrote:

 While cleaning up tests for release:
 
 .split(':')=
 
()# Perl 5
(,) # pugs
 
 Which is correct? It doesn's seem to be specced yet.

I would prefer the current pugs behavior; it's consistent with the general
case, in which a string which does not match the splitting regex results in
a single-item list containing the original string.  This is the Python
behavior.

I find the Perl5 (and, surprisingly, Ruby) behavior rather counterintuitive.




Re: Perl6 perlplexities [was: Re: $1 change issues...]

2005-11-07 Thread Mark Reed
On 2005-11-07 1:30 PM, Andrew Rodland [EMAIL PROTECTED] wrote:
 Especially when that complexity isn't optional. I
 think that's really a common fear, that Perl 6 is going well beyond that
 point of sensibility.
 
 If you want to get into personal beliefs, I think that function signatures are
 such a complexity quagmire -- and that they're line-noise ugly to boot.

But  the ugly and complex bits of function signatures are completely
optional.  In the usual case, you can just say

sub foo($x, $y) { do stuff with $x and $y }

Or

method foo($x, $y) { default invocant name used to do stuff with $x and $y }

And not have to worry about it.
 




Re: Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Mark Reed

On 2005-10-25 11:17 AM, Michele Dondi [EMAIL PROTECTED] wrote:
 I find $__ confusing, and prefer $OUTER::_, which already exists.
 
 Hmmm... maybe you're right that $__ is too huffmanized (and hence
 confusing) but $OUTER::_ is somewhat too few...

What's confusing about $__ is that it looks too much like $_.  In my font,
for instance, there's no gap - it's just a longer underline, which is far
too subtle a difference...





Re: Y [was: Re: new sigil]

2005-10-21 Thread Mark Reed
 Speaking of which, the advantage of, say, « over  is that the former
 is _one_ character. But Y, compared to ¥, is one character only as
 well, and is even more visually distinctive with most fonts I know of,
 afaict, so is there any good reason to keep the latter as the
 official one?!?

I can't speak for anyone else, but personally I prefer ¥ because I don't
like infix operators that look like identifiers.  It's idiosyncratic,
admittedly, but I dislike Pascal's mod and Perl5's x for the same
reason.  Even with the ability to use Unicode names, ¥ can't be an
identifier, because it's not a letter, it's a currency symbol.  Now that
we've opened up the Pandora's box of Unicode, we have lots more letters, but
also lots more non-letters, and I'd rather see the latter used for
operators.

Just my 2¢. :)




Re: new sigil

2005-10-21 Thread Mark Reed

On 2005-10-21 10:10 AM, Steve Peters [EMAIL PROTECTED] wrote:
 I saying that, since my up-to-date version of vi on my up-to-date OpenBSD
 can't type, much less even allow me to paste in, a Latin-1 character, this
 is an issue.

If you're using stock vi rather than vim or elvis or at least nvi,
up-to-date doesn't apply. :)   But the pasting problem has more to do with
your windowing and terminal environment, and I'd be surprised if there
weren't a simple tweak that would make it work for you.

 




Re: $1 change issues [was Re: syntax for accessing multiple versions of a module]

2005-10-21 Thread Mark Reed
On 2005-10-21 1:54 PM, Nate Wiger [EMAIL PROTECTED] wrote:
 BTW, C and PHP both use - still.

C++ is probably more relevant than C, but since it inherited the syntax,
same diff.  But in their case the underlying form is still a dot;  A-B is
just syntactic sugar for (*A).B. The distinction involved doesn't really
exist in Perl, so it only needed one form, and $Larry decided to go with dot
for concatenation and the arrow for dereferencing.  Then enough other
languages made the opposite choice that a rethink was warranted.

PHP was just copying Perl5, so it doesn't count. :)
 
 I really do understand that - really. But I think things are getting a
 bit overboard. The Latin-1 sigil is another discussion that nobody wants
 to admit is a legit problem, despite numerous legitimate issues. Even
 being able to type in the syntax itself is going to be problematic!

It's more a case of having had the discussion over and over again already, I
think.  Nothing came up in this thread that hadn't been said before.  The
design team is aware of the issues - really.  They simply have decided that
the trade-off in legibility worth it.

 Anyways, you can listen or not listen to those of us from real, large,
 corporate environments. I'm just trying to temper the enthusiasm for
 many of the real improvements in Perl 6 with some of the real costs -
 which are largely being ignored as no big deal.

Again, I don't think it's no big deal so much as already acknowledged and
stipulated.  For instance, we already have non-ASCII operators, so the
introduction of ¢ doesn't introduce any new issues of the sort being
discussed.


 I'm a big Perl advocate, but I guess I'm just not sure if I'm gonna be a
 big Perl 6 advocate yet. There's alot of downsides and real business risk.

I don't think there are a lot of downsides.  There is definitely a risk,
as with any new technology, and I'm largely adopting a wait-and-see attitude
myself, but I don't see any huge negatives anywhere.  What are these
downsides?

From a practical standpoint, it will be a while before I have to worry about
Perl6 professionally, because we're not going to want to use it until it's
been around long enough to have some kinks worked out.


 




Slightly OT: zip() for Perl5?

2005-10-21 Thread Mark Reed
Is there a CPAN module which provides the functionality of ¥/zip() for
Perl5?  I don't see anything obvious in the Bundle::Perl6 stuff.  Not hard
to write, of course, just wondering if it's been done . . .





Zip more than two arrays?

2005-10-21 Thread Mark Reed
Hm.  This brings up another point, which may have been addressed . . .

The Python function and Ruby array method zip() both accept any number of
arrays to interleave:

 zip([1,2,3],[4,5,6],[7,8,9])
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]

irb(main):001:0 [1,2,3].zip([4,5,6],[7,8,9])
= [[1, 4, 7], [2, 5, 8], [3, 6, 9]]

How would you write the above in Perl6, given that ¥/Y is an infix operator?


On 2005-10-21 5:32 PM, Mark Reed [EMAIL PROTECTED] wrote:
 Is there a CPAN module which provides the functionality of ¥/zip() for
 Perl5?




Re: 'self' and .foo (was: Re: Re(vised): Proposal to make class method non-inheritable)

2005-10-17 Thread Mark Reed

On 2005-10-15 15:28, Ilmari Vacklin [EMAIL PROTECTED] wrote:

 On Sat, Oct 15, 2005 at 09:49:30AM -0700, Larry Wall wrote:
 On Sat, Oct 15, 2005 at 07:39:36PM +0300, wolverian wrote:
 : IMHO just call it self (by default) and be done with it. :)
 
 Let it be so.
 
 Somewhat off-tangent: does this mean that .foo is always $_.foo?

tic

glazed, far-off look in the eye

INCOMING!!

opens desk drawer, rummages around for hand grenade


.
.
.

Hunh.  Who'da thunk - apparently even *flame* wars can trigger
post-traumatic stress disorder... 




Re: Sane (less insane) pair semantics

2005-10-10 Thread Mark Reed

On 2005-10-10 13:36, Ingo Blechschmidt [EMAIL PROTECTED] wrote:
 Under the proposal, a Pair object doesn't have any special
 magic 

Right.  So under this proposal, the key = value syntax is overloaded: in
some contexts it creates a Pair object, and in others it assigns a value to
a named parameter, and parentheses are the disambiguating mechanism to get
the former behavior in the latter context.  Meanwhile, a reference to a Pair
object occurring in an argument list does not interact with the
named-parameter mechanism at all.

At least, not by default.  It would be desirable to have a way to flatten a
hash/list of Pairs/whatever in such a way that it *does* map key names to
named parameters.




Re: Stringification, numification, and booleanification of pairs

2005-09-23 Thread Mark Reed
On 2005-09-23 06:08, Juerd [EMAIL PROTECTED] wrote:
 In my opinion, making the string value in interpolation different from
 the value in Str context is madness.

Hear, hear!  I agree 100%.  This is another place where we should move the
Rubyometer down rather than up, I think (to_s vs. to_str, anybody?).





Re: conditional wrapper blocks

2005-09-21 Thread Mark Reed



On 2005-09-21 03:53, Yuval Kogman [EMAIL PROTECTED] wrote:

 On Tue, Sep 20, 2005 at 21:09:09 +0200, Juerd wrote:
 Mark Reed skribis 2005-09-20 14:31 (-0400):
 This has so little redundancy that it makes very little sense to want to
 avoid repeating that very short encode_entities($item-label).
 
 The fine line is when the midsection is slightly more than that...

Watch the attributions, please.  I didn't write the above text - Juerd did.




Re: conditional wrapper blocks

2005-09-20 Thread Mark Reed
On 2005-09-20 14:23, Yuval Kogman [EMAIL PROTECTED] wrote:

 On Tue, Sep 20, 2005 at 18:19:42 +, [EMAIL PROTECTED] wrote:

 2: if the middle part does something that changes the value of  the
 expression $condition then the new construct again has a different meaning.
 
 Err, that's the point

Not necessarily.  Consider this common idiom (in pseudo-perl5):

foreach my $item (@menu)
{
print li\n;

if ($item is not the current page)
{
print qq|a href=${\($item-url)};
}

print $item-label;

if ($item is not the current page)
{
print /a;
}

print /li\n;
}

The middle unconditional part doesn't change anything; it's just that -
unconditional.  We want to do it every time regardless, but it's bracketed
by bits that always go together - we want to do either both or neither, but
never just one.





Re: Time::Local

2005-08-15 Thread Mark Reed
On 2005-08-15 10:07, Nicholas Clark [EMAIL PROTECTED] wrote:
 Spain adopted the Gregorian Calendar in 1582. Surely setting my locale to
 Spain should make the Julian/Gregorian jump show up in 1582, not 1752?

Arguably so, but I don't think there's anywhere in the POSIX localization
data structures to store that information.  There's a huge variety of
adoption dates, from Oct 5/15, 1582 (Most Catholic countries of Western
Europe) to March 10/23, 1924 (Greek civil usage).

Plus, even within its limited US/historical UK application, the cal(1)
program is still (admittedly so on its own man page) inaccurate for dates
prior to 1751, because it uses January 1 as the first day of the year.
While that was true in the original design of the calendar as instituted by
Caesar in 45 BC, and has been true in England and her colonies since 1751,
at some point way back when England had started counting the year change on
March 25.  That was a gradual change with no clear transition date, so
matching historical practice exactly is pretty much impossible for a large
chunk of Isle history.





Re: Time::Local

2005-08-15 Thread Mark Reed
On 2005-08-15 13:07, Mark A. Biggar [EMAIL PROTECTED] wrote:
 3) use Astronomical Dates which are kept as the number of days sense
 noon Jan-1-4713 BC.

More specifically, that's the astronomical Julian Day, or JD, and JD 0 began
at noon Universal Time (a.k.a. GMT) on January 1, 4713 BC in the Julian
calendar.  Sometimes this is called the Julian Astronomical Day, or JAD, to
distinguish it from various other misappropriations of the term julian
day/date.  

More generally, astronomers use the Gregorian calendar like the rest of us,
but often extend it into the past before its adoption, ignoring the Julian
calendar switchover.  They also tend to use 0 and negative years AD/CE in
lieu of BC(E) numbering.  On that basis, JD 0 began at noon on Nov 24,
-4713.

Julian Days make a good neutral format for storing dates (and, with
fractional components, times), but they are a bit cumbersome.  If you don't
actually need the range they provide  (because you're only dealing with
dates near the present), it might be regarded as overkill to store the
current time as e.g. 2453598.225995.  In order to get 1-second resolution,
the JD requires the same number of significant figures that's required to
get millisecond resolution with time_t.









Re: Time::Local

2005-08-15 Thread Mark Reed

On 2005-08-15 15:04, Doug McNutt [EMAIL PROTECTED] wrote:

 At 13:31 -0400 8/15/05, Mark Reed wrote:
 If anyone gets serious about Julian dates there is also the Modified Julian
 Date, MJD, used by the US military and others. It differs from the JAD above
 by a large well-defined integer plus 1/2.
The (then) most recent even multiple of 100,000 was chosen for it: MJD 0 =
JD 2,400,000.5.

 The result is a day that begins at
 midnight and starts at a more recent date that I don't remember. It's not Jan
 0, 1970 though.
November 17, 1858.  Which, while not Jan 1, 1970, is still time zero for
another operating system some of you may have heard of: VMS.

There's also something called the Truncated Julian Day/Date, or TJD, which
NASA used to use: it was essentially the last four digits of the MJD, so
that TJD 0 was MJD 4, aka May 24, 1968.  But once MJD 5 rolled
around (on Oct 10, 1995), the TJD became ambiguous.  Besides, while saving a
decimal digit of storage per log entry was significant when NASA was trying
to get computers light enough to launch in the 1960s, it's not exactly an
earth-shattering storage win today.  So the TJD is best avoided.  In fact,
forget I mentioned it. :)




Re: Time::Local

2005-08-15 Thread Mark Reed
On 2005-08-15 13:56, Larry Wall [EMAIL PROTECTED] wrote:
 I'm personally rooting for everyone to abandon leap seconds for civil time.

While you're at it, why not wish for DST to go away (or to become permanent
year-round, whichever)?  Heck, toss in world peace, too. :)

 But POSIX stretchy seconds must die.

So Say We All.





Re: Time::Local

2005-08-15 Thread Mark Reed
On 2005-08-15 13:56, Larry Wall [EMAIL PROTECTED] wrote:
 Perl 6 will natively think of dates as number of floating point TAI
 seconds from the year 2000.  You can build any kind of date interface
 on top of that, but we're going for simplicity and predictability.

I applaud that decision.  I just have one question: will the zero point be
chosen according to TAI or UTC?

I would assume that you would choose time 0.0 =  Jan 1, 2000 at 00:00:00.0
TAI (December 31, 1999 at 23:59:29.0 UTC), making the whole thing free of
any UTC interferences.  But there is an argument for making the zero point a
recognizable boundary in civil time.  The Olson library does that (its zero
point is 00:00:10.0 TAI on Jan 1, 1970), but that's only because it's
designed to be a drop-in replacement for the standard POSIX library and the
time_t values have to match.  Since you're changing the epoch, there's no
compatibility constraint here . . .









Re: Perl 6 Meta Object Protocols and $object.meta.isa(?)

2005-08-08 Thread Mark Reed
Coming in late here, but it seems odd to have an actual class called
MetaClass.  The meta-object protocols with which I am familiar have the
concept of a metaclass (a class whose instances are themselves classes), and
the class Class is such a metaclass, but where does a class named MetaClass
fit in?  If all metaclasses are instances of MetaClass, then MetaClass must
be an instance of itself - is this then the only cycle in the graph?

 1) MetaClass is a subclass of Object
 2) MetaClass is an instance of MetaClass

OK.
 
 So the following code should be true (given a random instance $obj).
 
$obj.meta.isa(MetaClass);
$obj.meta.isa(Object);

What does $obj.meta return - is it just a shortcut for $obj.class.class, or
is something else going on here?

If the former, then all of these should be true.

$obj.isa(Object)
$obj.class.isa(Object)
$obj.class.isa(Class)
$obj.meta.isa(Object)
$obj.meta.isa(Class)
$obj.meta.isa(MetaClass)


 However, Syn/Apoc 12 shows that the following is true if $foo is an
 instance of the Foo class.
 
$foo.meta.isa(Foo)

Hm.  That doesn't make sense to me at all.  Clearly I need to reread the
Syn/Apoc.  I'd expect $foo.isa(Foo) and that's it, although if nothing fancy
with composition is going on $foo.class == Foo would also be true.





Re: $pair[0]?

2005-08-05 Thread Mark Reed
Seems like you left out the degenerate case for when you run out of pairs:

sub infix:!! (Scalar $x, 0) { $x }



On 2005-08-05 16:24, Yuval Kogman [EMAIL PROTECTED] wrote:

 On Fri, Aug 05, 2005 at 11:36:16 -0700, Larry Wall wrote:
 
 There's something to be said for having a way of indexing into that
 using numeric subscripts.  Certainly Lisp's extensible car/cdr notation
 is the wrong way to do it, but cdddr is certainly shorter than
 
 $pair.value.value.value
 
 But maybe that's worth being dehuffmanized like that...
 
 Haskell has !! :
 
 sub infix:!! (Pair $x, 0) { $x.key }
 sub infix:!! (Pair $x, Int $index) { $x.value !! ($index - 1) }




Re: MML dispatch

2005-07-12 Thread Mark Reed
On 2005-07-11 23:46, Damian Conway [EMAIL PROTECTED] wrote:
 3. Work out the Manhattan distance from the argument list to each
variant's parameter list.

OK, sorry if I missed this in an earlier discussion.  For purposes of
calculating this Manhattan distance, I gather that we're treating lists of N
arguments/parameters as points in N-space.  I further assume that the
monoaxial distance between a parameter coördinate and the corresponding
argument coördinate - the distance between two types, where the types are
known to be assignment-compatible - is the number of inheritance steps
between them?

And one more dumb question: why is it that the L[1] metric is superior to
the L[2] metric for this purpose?





Re: MML dispatch

2005-07-12 Thread Mark Reed
On 2005-07-12 12:22, TSa (Thomas Sandlaß) [EMAIL PROTECTED]
wrote:
 I am also interested in the rationale behind the approach to manage MMD
 my means of a metric instead of a partial order on the types.
 Metric is a geometric concept which in my eyes doesn't fit type
 theory. 

The geometric interpretation does bring us into somewhat philosophical
territory. Not that that's anything new on this list. :)

Let me try a concrete example.  Suppose that class Answer has subclasses
Animal, Vegetable, and Mineral, with respective subclasses Dog, Potato, and
Diamond.  There are two methods named foo in scope, neither overriding the
other.  One is declared to take (Animal, Vegetable, Mineral), the other
(Dog, Potato, Answer).  Assuming the obvious memberships, which method
should foo(Snoopy, Mr_PotatoHead, HopeDiamond) call?  And more importantly,
why do you feel that is the right answer?
 
According to Damian's metric, we have distances of 0+0+2=2 and 1+1+1=3, so
(Dog, Potato, Answer) is closer and would get called.  




Re: mod/div

2005-05-31 Thread Mark Reed
On 2005-05-30 05:15, TSa (Thomas Sandlaß) [EMAIL PROTECTED]
wrote:

 Mark Reed wrote: 
 I would really like to see ($x div $y) be (floor($x/$y))
 
 That is: floor( 8 / (-3) ) == floor( -2. ) == -3
 Or do you want -2?
 
 and ($x mod $y) be ($x - $x div $y).
 
 Hmm, since 8 - (-3) == 11 this definition hardly works.

Sorry.  As you surmised, I left off a multiplication.
($x mod $y) should be ($x - $y * ($x div $y)).


 But even with $q = floor( $x / $y ) and $r = $x - $q * $y
 we get 8 - (-3) * (-3) == -1 where I guess you expect -2.

Why would I expect -2?  I don't actually have an preconceptions for negative
divisors.  But after just now taking a second to think about it, I would
expect it to generalize such that 0 = abs($r)  abs($y), with sgn($r) in
{0, sgn($y)}.  So having (8 div -3) == -3 and (8 mod -3) == -1 works fine,
especially since it's consistent with (-8 div 3) == -3 and (-8 mod 3) == 1,
as given by my (corrected) formulae above.

 Looks like you want some case distinction there on the
 sign of $x. 

Absolutely not!  My entire goal is to avoid ever having to do something like
this:

if ($x  0) 
{
$y = formula1($x);
}
elsif ($x == 0)
{
$y = formula2($x);
}
else
{
$y = formula($x);
}

At least, not in cases where the intended result is consistent across 0.
Lots of date arithmetic falls into this category, and works beautifully with
the definitions above.  It lets me do things without bounds checking and
correct the ranges later, because, e.g., plugging in January -20, 0 AD
yields the correct result for December 11, 2 BC.  Such calculations break
dramatically across 0 if you use the definition found in some C
implementations, where (-3 mod 5) == -3.

 If there is a definition that needs no special casing
 then it is the euclidean definition that 0 = $r  abs $y.

In which case, for or your example of 8 == $q * (-3) + $r, $q == -2 and $r
== +2?  Seems odd to me that just swapping the signs (from -8,3 to 8,-3)
yields completely different numbers like that.





Re: (1,(2,3),4)[2]

2005-05-25 Thread Mark Reed
[1,2,3] is not an array or a list.  It is a reference to an anonymous array.
It is not 3 values; it¹s 1 value, which happens to point to a list of size
3.  If you assign that to an array via something like @a = [1,2,3], I would
expect at least a warning and possibly a compile-time error.

 If it does work, it probably gets translated into @a = ([1,2,3]), which
creates an array of size 1 whose first (and only) element is a reference to
an array of size 3.  That would give this result:

[EMAIL PROTECTED] == 1;

@a[0] == [1,2,3]; 
@a[1] == undef; 
@a[0][0] == 1;
@a[0][1] == 2; 
@a[0][2] == 3;

I¹m not sure about +(@a[0]), but I¹m guessing it would == 3.





On 2005-05-25 04:47, TSa (Thomas Sandlaß) [EMAIL PROTECTED]
wrote:

 Juerd wrote: 
  An array in scalar context evaluates to a reference to itself.
  
  A hash in scalar context evaluates to a reference to itself.
  
  An array in list context evaluates to a list of its elements.
  
  A hash in list context evaluates to a list of its elements (as pairs).
  
  Array context is a scalar context.
 
 I have understand what you mean and how you---and other p6l'er---
 derive [EMAIL PROTECTED] == 1 from @a = [1,2,3]. But allow me to regard this
 as slightly inconsistent, asymmetric or some such.
 
 Isn't hash context missing in the list above? How does
 
 %a = ( a = 1, b = 2, c = 3 )  # @a = (1,2,3)
 
 compare with 
 
 %b = { a = 1, b = 2, c = 3 }  # @b = [1,2,3]
 
 Does that mean 
 
 3 == +%a == +%b 
== +{ a = 1, b = 2, c = c }
== +( a = 1, b = 2, c = c )
 
 holds and the access of the hash works as expected:
 
 %aa == 1 == %ba  # and @a[0] == 1, but @b[0][0] == 1
 
 What would actually be the equivalent syntax to @b?
 Is it %ba or %%ba or even (*%b)a?
 It will hardly be %b{undef}a, though.




Re: (1,(2,3),4)[2]

2005-05-25 Thread Mark Reed



On 2005-05-25 13:54, Juerd [EMAIL PROTECTED] wrote:

 3.  If you assign that to an array via something like @a = [1,2,3], I would
 expect at least a warning and possibly a compile-time error.
 
  If it does work, it probably gets translated into @a = ([1,2,3]), which
 
 That's not a translation. Parens, when not postfix, serve only one
 purpose: group to defeat precedence. $foo and ($foo) are always the same
 thing, regardless of the $foo.

So, you could then do this to make an array of size 3 in Perl6?

@a = 1,2,3;




Re: mod/div (was: reduce metaoperator on an empty list)

2005-05-23 Thread Mark Reed
I would really like to see ($x div $y) be (floor($x/$y)) and ($x mod $y) be
($x - $x div $y).   If the divisor is positive the modulus should be
positive, no matter what the sign of the dividend.  Avoids lots of special
case code across 0 boundaries.


On 2005-05-23 18:49, TSa (Thomas Sandlaß) [EMAIL PROTECTED]
wrote:

 [EMAIL PROTECTED] wrote:
  There are actuall two usefull definition for %.  The first which Ada calls
 'mod' always returns a value 0=XN and yes it has no working value that is
 an identity.  The other which Ada calls 'rem' defined as follows:
 
  
  Signed integer division and remainder are defined by the relation:
  
  A = (A/B)*B + (A rem B)
  
 where (A rem B) has the sign of A and an absolute value less than the
 absolute value of B. Signed integer division satisfies the identity:
 
  
  (-A)/B = -(A/B) = A/(-B)
  
  It does have a right side identity of +INF.
 
 This is the truncating div-dominant definition of modulo.
 The eulerian definition is mod-dominant and nicely handles
 non-integer values. E.g.
 
   3.2 == 1.5 * 2 + 0.2 -+--  3.2 / 1.5 == 2 + 0.2 / 1.5 == 2 + 1/15
 |   == 2 + 0.1333...
 +--  3.2 % 1.5 == 0.2
 
 Note that -3.2 == -4 + 0.8 == -4.5 + 1.3 == ...
 
-3.2 / 1.5 == -3 + 1.3 / 1.5 == -3 + 0.8666... == -2.1333
-3.2 % 1.5 ==  1.3
 
 With integers: 
 
   8  /   3  ==  (2 + 2/3) ==  2
   8  / (-3) == -(2 + 2/3) == -2
 (-8) /   3  == -(3 - 1/3) == -3  # this might surprise some people ;)
 (-8) / (-3) ==  (3 - 1/3) ==  3
 
   8  % (-3) ==   8  % 3 == 2
 (-8) % (-3) == (-8) % 3 == 1  # this as well, but it's just -3 * 3 + 1
 
 Real valued division can be considered as % 0, that is infinite precision.
 While integer arithmetic is % 1. I.e. int $x == $x - $x % 1.
 
 floor $x == $x - $x % 1# -1.2 - (-1.2) % 1 == -1.2 - 0.8 == -2
 ceil  $x == 1 + floor $x
 round $x == floor( $x + 0.5 )
 trunc $x == $x  0 ?? ceil $x :: floor $x
 
 To @Larry: how are mod and div defined in Perl6?




Re: Nested captures

2005-05-17 Thread Mark Reed



On 2005-05-17 14:14, Peter Haworth [EMAIL PROTECTED] wrote:\
 
 Does numbering of captures after an alternation continue as if the
 alternative with the most captures matched?
 
 #   $1$1  $2$3, even if (a) matched
   rx/ [ (a) | (b) (c) ] (d) /;

I thought that was still like Perl5:

 #   $1$2  $3$4
   rx/ [ (a) | (b) (c) ] (d) /;

The *numbering* is based on the regex; the *values* are based on the actual
match.

What's changed in the Perl6 design, AIUI, is nested captures.  Given this:

 rx/ (a (b (c d) e) f) /

In Perl5, $1 is abcdef, $2 is bcde, and $3 is cd.  In the proposed
Perl6 model, there is no $2, just $1 (an object which stringifies to
abcdef, $1.1 (an object which stringifies to bcde), and $1.1.1 (an
object which stringifies to cd.




 

 
 
 If you explicitly number the first capture in one alternative, does that
 affect the numbering of the other alternatives?
 
 #   $4$4
   rx/ [ $4:=(a) | (b) ] /;
 
 
 Note that, outside a rule, C@1 is simply a shorthand for C@{$1}
 
 Is @/ also a shorthand for @{$/} ?
 





Re: Open and pipe

2005-05-02 Thread Mark Reed
On 2005-05-02 15:52, Juerd [EMAIL PROTECTED] wrote:

 Gaal Yahas skribis 2005-05-02 22:25 (+0300):
   open 'ls', '|-'; # or even
   open 'ls', :pipe = 'from'
 
 I dislike the hard-to-tell-apart symbols '' and '' for modes. 'r' and
 'w' are much easier, and get rid of the awful left/right mnemonic that
 fails to make sense to GUI users.
 
Holy matter of opinion, Batman.  ŒŒ and Œ¹ are much easier to tell apart
than Œr¹ and Œw¹;
Œr¹ and Œw¹ make me stop and think about how you spell Œread¹ and Œwrite¹,
whereas ŒŒ and Œ¹ make instant visual sense, which should be appreciated
by GUI users of all people.

Left-to-right is hardly a mnemonic; you¹re writing in a language which
parses left to right, because it was created by English-speakers, and
English is written left to right.  Since you pretty much have to learn
English to learn Perl, I don¹t think this is too much of a hardship, even if
it¹s counterintuitive to native speakers of Semitic languages.

And since when is Perl targeting GUI users?  It¹s a PROGRAMMING LANGUAGE.
Even the original Mac developers used a command-line interface when writing
the code.





Re: Open and pipe

2005-05-02 Thread Mark Reed
I take some of that back ­ actually, left-to-right directionality has almost
nothing to do with understanding the  and  symbols.  The arrow points in
the direction information is flowing, which is left-to-right for  but
right-to-left for .   I mean, ³filename² is pointing at the file, so the
information is flowing into the file; ³filename² is pointing away from the
file, so the info is flowing out of it.  I don¹t see how it could be any
clearer than that.


On 2005-05-02 16:13, Mark Reed [EMAIL PROTECTED] wrote:

 On 2005-05-02 15:52, Juerd [EMAIL PROTECTED] wrote:
 
 Gaal Yahas skribis 2005-05-02 22:25 (+0300):
   open 'ls', '|-'; # or even
   open 'ls', :pipe = 'from'
 
 I dislike the hard-to-tell-apart symbols '' and '' for modes. 'r' and
 'w' are much easier, and get rid of the awful left/right mnemonic that
 fails to make sense to GUI users.
 
 Holy matter of opinion, Batman.  ŒŒ and Œ¹ are much easier to tell apart
 than Œr¹ and Œw¹;
 Œr¹ and Œw¹ make me stop and think about how you spell Œread¹ and Œwrite¹,
 whereas ŒŒ and Œ¹ make instant visual sense, which should be appreciated by
 GUI users of all people.
 
 Left-to-right is hardly a mnemonic; you¹re writing in a language which parses
 left to right, because it was created by English-speakers, and English is
 written left to right.  Since you pretty much have to learn English to learn
 Perl, I don¹t think this is too much of a hardship, even if it¹s
 counterintuitive to native speakers of Semitic languages.
 
 And since when is Perl targeting GUI users?  It¹s a PROGRAMMING LANGUAGE.
 Even the original Mac developers used a command-line interface when writing
 the code.
 
 
 




Re: Open and pipe

2005-05-02 Thread Mark Reed

On 2005-05-02 16:35, Juerd [EMAIL PROTECTED] wrote:
 What are the characters around the code supposed to be, by the way? Your
 mailer tells my mailer that you're sending iso-8859-1, but I seriously
 doubt that. 
 
Argh.  Bad Entourage, no biscuit.   Back to Mail as soon as I get Tiger
installed, I think.
 
 But of course, I also find it hard to believe someone's actually using
 Microsoft software to send something to a geek mailinglist. ;)

I had good reasons for switching to it at one time.  Honest!  Besides, it¹s
a work thing.

 PROGRAMMING LANGUAGE doesn't translate to LANGUAGE USED BY PEOPLE WHO
 ALL USE COMMAND LINE UTILITIES ALL THE TIME. In fact, many people use
 graphical IDEs and don't like the command line.
 
 I have nothing against IDEs; IDEA is pretty nice for Java coding, for
instance.  But to date most Perl programmers don¹t program Perl inside an
IDE, although it would be nice if Perl 6 had an IDE coming out of the box.

My point was simply that people who program are in general more technically
savvy than those who don¹t.  That doesn¹t mean they use the command line
exclusively, or at all, but it does mean that they should be capable of
understanding visual metaphors other than those of the GUI world.









Re: Adding Complexity

2005-04-28 Thread Mark Reed

 Jonathan Lang wrote:
  When you take the square root of a number, you actually get one of two
  possible answers (for instance, sqrt(1) actually gives either a 1 or a
  -1).

Not quite.  It¹s true that there are two possible square roots of any given
number, but sqrt(1) is defined as the positive one.The radical sign is
also defined as the positive one in standard mathematical notation, btw; you
have to put a +/- in front of it to get the ³junctive² value.


Re: invocant vs. topic (was: Re: -X's auto-(un)quoting?)

2005-04-26 Thread Mark Reed
I¹m only an amateur linguist, but from a linguistic point of view, there are
several related terms in this space.

The term ³subject² has many meanings in English, including ³topic².  But
from a grammatical and linguistic standpoint, there are only two meanings of
³subject², and ³topic² is a distinct term.

One meaning of ³subject² is specific to the grammar of a given language,
such as English, in which we have ³subjects² and ³objects².  The more
general linguistic term is usually capitalized (³Subject²) and even more
usually abbreviated as ³S²; it refers only to what we call the subject of an
intransitive verb.  What we call the subject of a transitive verb is more
generally called the ³Agent², or ³A², and what we call the direct object of
a transitive verb is more generally called a ³Patient², or ³P².  Different
languages group S, A, and P differently in how they are treated by the
grammar; English, like most European languages, lumps S and A together and
separates P; such languages are called ³nominative-accusative² (or just
³accusative²) languages.

Then you have ³topic² and ³focus², which are closely related.  Basically,
the focus is the main thing that you¹re talking about in a given sentence,
and is usually introduced by that sentence.  The topic is a known quantity
under discussion.  So you frequently have the focus of one sentence ­ which
may or may not be its subject - being the topic for subsequent discussion.

Example:

A) I went to the game yesterday.
B) While there, I saw Smoltz strike out 15 batters.

The grammatical subject of sentence A is ³I²,  and it is actually a Subject
in SAP terms.  But the focus is the game.  The definite article implies that
the listener knows which game is being discussed, but it¹s still being
introduced as a new element here.  If there is a topic, we don¹t know what
it is.

The grammatical subject of B is still ³I², but this time it¹s an Agent; the
Patient is an action (Smoltz striking out 15 batters), and that action is
also the focus.  But  the topic is the game.



Re: -X's auto-(un)quoting?

2005-04-22 Thread Mark Reed
 Anyway, is there any other URI scheme besides for mailto: that doesn't use
 ://? 
 
 It¹s optional for news:; news:comp.lang.perl is a valid URI for accessing that
 Usenet newsgroup via whatever your default news server is.
 
 There aren¹t any slashes in the aim: scheme (not part of the IANA standard,
 but widely supported for accessing AOL-compatible IM clients from web
 browsers).
 
 There are no slashes in tel: (telephone numbers), though I don¹t know what you
 could do with those from Perl. :)
 
 And I¹m sure there are others.  The syntax after the colon is pretty much
 arbitrarily determined by the scheme prefix, so a global constraint on it is a
 bad idea.
 
 -Mark



Re: nbsp in \s, ?ws and

2005-04-15 Thread Mark Reed
I thought we had just established that nbsp is not in Unicode¹s definition
of whitespace.  So why should \s match it?



On 2005-04-15 18:56, Larry Wall [EMAIL PROTECTED] wrote:

 On Sat, Apr 16, 2005 at 12:46:47AM +0200, Juerd wrote:
 : Larry Wall skribis 2005-04-15 15:38 (-0700):
 :  : Do \s and ?ws match non-breaking whitespace, U+00A0?
 :  Yes. 
 : 
 : That makes \s+ and \s*, and thus ?ws very useless for anything but
 : trimming whitespace. For splitting (including word wrapping), it'd do
 : exactly the wrong thing.
 
 Maybe we just need a bws for breaking white space, or some such.
 ?ws is primarily used in pattern matching with :w, where a
 non-breaking space in the input would presumably be matched by a
 non-breaking space in the pattern, or maybe an explicit nbsp.
 As long as patterns (with or without :w) treat non-breaking spaces
 as ordinary matching characters, it should work out, methinks.
 Though it's probably a hair more readable to use an explicit nbsp...
 
 Larry 
 




Re: Whither use English?

2005-04-11 Thread Mark Reed

On 2005-04-11 15:00, Juerd [EMAIL PROTECTED] wrote:
 
 I'm not even sure I like the *possibility* of using non-ascii letters in
 identifiers, even.


I agree that it would be a nightmare if project A used presu instead of
print everywhere, while project B used toon, etc.  But non-ASCII identifiers
are a good thing, because there are many places even in the English-speaking
world  even in Ugly America  where people are used to such identifiers.  I
want to be able to use $ for a variable representing angstroms, to see the
constant Math::Trig:: in trig functions,  to declare a sub  that does
summations, etc etc.  And even if those dont come through in email
properly, they make it through CVS/SVN commits and updates just fine. :)





Re: Question about list context for String.chars

2005-04-11 Thread Mark Reed

On 2005-04-11 15:40, gcomnz [EMAIL PROTECTED] wrote:
 

.chars would return [EMAIL PROTECTED]@, which can probably be 
expressed
with UTF8?

The string  is probably represented internally as UTF-8, but that
should have no effect on what .chars returns, which should, indeed, be 
[EMAIL PROTECTED], that is, an array whose elements are strings which each 
represent
one Unicode code point  irrespective of encoding.

I think that, in general, at the level of Perl code, 1 character should be
one code point, and any higher-level support for combining and splitting
should be outside the core, in Unicode::Whatever.






Re: :=: (OT)

2005-04-04 Thread Mark Reed

:set encoding=utf8
:set fileencoding=utf8

The first controls the display, the second file saves.  Vim has to have been
compiled with multibyte support, though.


From: Aaron Sherman [EMAIL PROTECTED]
Date: Mon, 4 Apr 2005 17:01:58 -0400
To: Larry Wall [EMAIL PROTECTED]
Cc: Perl6 Language List perl6-language@perl.org
Subject: Re: :=: (OT)


The default mode for my vim was Latin-1. I was being lazy because I knew
how to tell gnome-terminal to do Latin-1, but I have no clue how to tell
vim to display and save UTF-8. I'm sure it's easy enough though.

On second thought... do I really want to have to figure out:

$pie = $face;

or is that: 

$pie;