RE: Do we really need eq?

2000-08-30 Thread Fisher Mark

Al Lipscomb writes:
I was wondering about maybe being able to store these 
 attributes as
 optional parts of the scalar. Something like this (please 
 don't get hung up
 on the details, I am not much of a designer):
 
my($amt,$hours,$total);
$amt-{TYPE} = "DOLLARS";
$total-{TYPE} = "DOLLARS";
$hours-{TYPE} = "INTEGER";

I've seen this kind of idea tossed around for a number of years (my first
recollection is a SIGPLAN article in the early 1980's, although I'm sure the
idea dates before then).  For those of us in the engineering world, it would
help with making sure we were using the right sort of units all the time.
(Mars Climate Orbiter, anyone?)  But IMHO this only works if:
* Units of measure are optional;
* Units of measure are fast; and
* Implementing units of measure don't appreciably slow down computations
that don't use units of measure.

Mark Leighton FisherThomson Consumer Electronics
[EMAIL PROTECTED] Indianapolis, IN, USA
"Display some adaptability."  -- Doug Shaftoe, _Cryptonomicon_




Re: Do we really need eq?

2000-08-30 Thread David L. Nicol

Fisher Mark wrote:

 * Units of measure are optional;
 * Units of measure are fast; and
 * Implementing units of measure don't appreciably slow down computations
 that don't use units of measure.

enforced types without automatic conversions does all this, the matches
are made once at compile-time and then they use the native math ops.

Dynamic types-checking slows us down of course, but with both, the
dynmaic type will only be required when it isn;t clear, and that clarity
will keep perl6 instructors with full classrooms.



-- 
  David Nicol 816.235.1187 [EMAIL PROTECTED]
   Subroutine one-arg, him called no-arg, get $_-arg.  Ug.



Re: Do we really need eq?

2000-08-29 Thread Peter Scott

At 12:57 PM 8/29/00 -0500, David L. Nicol wrote:
I'd like to see every number bundled with a "precision" attribute.  It's
a holdover from when I was heavily into chemistry.

Some of the other RFCs on the list also appear to have been triggered the 
same way.

Oh, wait...

:-)

--
Peter Scott
Pacific Systems Design Technologies




RE: Do we really need eq?

2000-08-29 Thread Lipscomb, Al


I'd like to see every number bundled with a "precision" attribute.  

That's not what I call a high-level language feature.  People don't
want to think about that, nor about machine-level precision issues.
See REXX.

In fact, I'd rather to see a painless and transparent int-float-bignum
autoconversion happen, the way currently we (theoretically) see the
int-float one occur.  

In some of the OO stuff people (me included) wanted to see simple scalars be
able to act "like" objects. Others have talked about allowing for strong
typing. I was wondering about maybe being able to store these attributes as
optional parts of the scalar. Something like this (please don't get hung up
on the details, I am not much of a designer):

   my($amt,$hours,$total);
   $amt-{TYPE} = "DOLLARS";
   $total-{TYPE} = "DOLLARS";
   $hours-{TYPE} = "INTEGER";
   $total-{PICTURE} = "$zzz,zz0.00"; # seen any COBOL in Perl, can't
remember the Perl equiv?
   #
   $total = $amt * $hours;
   # for strict type checking
   $total-{ASREAL} = $amt-{ASREAL} * $hours-{ASREAL};

does the concept make any sense (God help the example)? The idea being that
when strong type checking is turned on the first multiplication example
would flag a warning.






Re: Do we really need eq?

2000-08-29 Thread Andy Dougherty

On Tue, 29 Aug 2000, David L. Nicol wrote:

 I'd like to see every number bundled with a "precision" attribute.

While that might be useful for simple calculations, I expect it would
simply get in the way and slow things down for larger, more complex
calculations.

Alas I don't think there's any shortcut for actual analysis of the
underlying data and algorithms.

Andy Dougherty  [EMAIL PROTECTED]




Re: Do we really need eq?

2000-08-29 Thread Dan Sugalski

At 02:49 PM 8/29/00 -0400, Andy Dougherty wrote:
On Tue, 29 Aug 2000, David L. Nicol wrote:

  I'd like to see every number bundled with a "precision" attribute.

While that might be useful for simple calculations, I expect it would
simply get in the way and slow things down for larger, more complex
calculations.

It'd also tend to freak people out when this:

my $foo : sig_figs(1) = 2;

print 3.1415926 * $foo;

printed out 6. You think we have bug reports from floating point issues now...

Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk




Re: Do we really need eq?

2000-08-28 Thread Steve Simmons

I'd like to see eq and it's brethen retained, as dammit there are times
I want to know (-w) if numbers are turning up when there should be
words and vice-versa.  However, spinning off of something Randal wrote:

 Yes, but what about:
 
 $a = '3.14'; # from reading a file
 $b = '3.1400'; # from user input
 
 if ($a == $b) { ... } # should this be string or number comparison?

Since we have distinct comparison operators for strings and numbers, and
since we have explict casting for those who wish it, IMHO one can do

if ( int( $a ) == int( $b ) ) 

to force int (or float) compares, and

if ( "$a" eq "$b" )

to force string compares, 

IMHO the code

$a = '3.14'; # from reading a file
$b = '3.1400'; # from user input
if ($a == $b) { ... }

should see the two args being tested in numeric context, do the numeric
casting, get floats, and do a floating compare.  Durned if I know what it
does now.



Do we really need eq?

2000-08-20 Thread Ed Mills

Is eq needed? Can't == be used for either context?

   $a == 'cat'

is readily distinguishable from

   $a == 2;

so the compiler should be able to determine context.


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com




Re: Do we really need eq?

2000-08-20 Thread Spider Boardman

On Sun, 20 Aug 2000 17:50:20 -0600 (MDT), Nathan Torkington wrote (in part):

Nat Ed Mills writes:
 Is eq needed? Can't == be used for either context?  $a ==
 'cat' is readily distinguishable from $a == 2; so the compiler
 should be able to determine context.

Nat if ($a == $b)

Nat Is that string comparison or numeric comparison?

Consider that case in particular when $a and $b are each
dual-valued (valid as both string and number).

-- 
Spider Boardman (at home) [EMAIL PROTECTED]
The management (my cats) made me say this.http://www.ultranet.com/~spiderb
PGP public key fingerprint: 96 72 D2 C6 E0 92 32 89  F6 B2 C2 A0 1C AB 1F DC