Re: Masak List, take 3

2009-03-09 Thread Timothy S. Nelson

On Mon, 9 Mar 2009, Patrick R. Michaud wrote:


On Fri, Mar 06, 2009 at 01:37:16PM +1100, Timothy S. Nelson wrote:

I guess the way I decide things like this is:
-   If it's a method on a role/object, then it lives in S32
-   If it's not a method, then it lives in S29


Do we have many things that aren't methods?


	As few as possible :).  The things that remain in S29 are mostly not 
methods, but even a few of those are.



* Should there be a way to extract information about a Rat's
numerator/denominator? What methods does a Rat have?


I'm also curious about extracting real and imaginary components
from Complex.


Specced.  Feel free to suggest name changes.


# true(), not(), also methods


On?


C is a method on Object (S02:3391), I suspect that
C is also (S03:3282).

Beyond that, I think that what one would think of as
true() or not() are really prefix: and prefix:,
and not "functions" in the normal sense.


	Operators, rather than functions?  But if they're also methods, won't 
they have to be defined separately, rather than putting "is export" on the 
method?


:)


-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI D G+ e++> h! y-

-END GEEK CODE BLOCK-



Re: Masak List, take 3

2009-03-09 Thread Patrick R. Michaud
On Fri, Mar 06, 2009 at 01:37:16PM +1100, Timothy S. Nelson wrote:
>   I guess the way I decide things like this is:
> - If it's a method on a role/object, then it lives in S32
> - If it's not a method, then it lives in S29

Do we have many things that aren't methods?

>> * Should there be a way to extract information about a Rat's  
>> numerator/denominator? What methods does a Rat have?

I'm also curious about extracting real and imaginary components
from Complex.

>> # true(), not(), also methods
>
>   On?

C is a method on Object (S02:3391), I suspect that 
C is also (S03:3282).

Beyond that, I think that what one would think of as
true() or not() are really prefix: and prefix:,
and not "functions" in the normal sense.

Pm


Rat information extraction (was Re: Masak List, take 3)

2009-03-06 Thread Darren Duncan

Timothy S. Nelson wrote:
* Should there be a way to extract information about a Rat's 
numerator/denominator? What methods does a Rat have?


Rat.avoid_trap(), Rat.eatcheese(), Rat.race(), etc.  Oh, wait, 
*that* kind of Rat :).


Don't forget that a Rat can have at least one other good representation in terms 
of integers.


While the numerator/denominator pair is good, I say that the 
mantissa*radix^exponent triple is better, especially so when representing very 
large or very small numbers like in the generalization of an IEEE-754 floating 
point number (but, with the most common actual IEEE-754 values, the radix is 
always 2).


With the triple, then typically the size of integers we are dealing with are not 
larger than the size of the mantissa portion, which corresponds directly to the 
amount of precision we have, and the radix/exponent would tend to be just 1-5 
digits or so.


In contrast, with numerator/denominator, if you wanted to represent, say, 10^30 
or 10^-30, you would use at least 30 decimal digits even if your precision is 
say 5 digits, and most of your digits are effectively or actually zeros.  So 
math with the triple may be slightly more complicated than with the pair, but 
not by much, and it scales a lot better.


In the interest of TIMTOADY, I suggest that Rat be a role and at least 2 
implementations exist, one using the pair internally, and one using the triple 
internally (both can exactly represent every rational), since each would perform 
better for different scenarios, and you could get silent conversions between 
them by operators when that makes sense; in any event they would both support 
exactly the same accessors, so users could extract either the pair or the triple 
from either.  I think you do not want the pair being the only representation.  I 
think it also goes without saying that using === on 2 values of different said 
representations will mutually normalize and compare on the actual rational 
numeric values.


Or maybe this isn't really the domain of role exposure and the internals of pair 
vs triple are really just banished to the implementation details that aren't 
exposed in the language.  Same as with silently using machine ints vs big ints 
behind Int as the situation warrants.  And then there's no worrying about === or 
whatever not just working.  So then the main thing for the language to care 
about is just that information about a Rat in terms of Ints can be extracted in 
either format.


-- Darren Duncan


Masak List, take 3

2009-03-05 Thread Timothy S. Nelson

I've done some more fiddling based on Carl Masak's updated list.

   *  I see the sub version of defined declared in S29. Is the method 
version (used in S02:519) also in S29? I can't see it, but I might be 
missing something about how method signatures work.


I've moved it to S32/Any.pod, and declared the method version.

* Should the methods .new and .clone be covered by S29? They're slightly 
different beasts than abs or push, but they're still in a sense "builtin 
functions in Perl 6".


I guess the way I decide things like this is:
-   If it's a method on a role/object, then it lives in S32
-   If it's not a method, then it lives in S29
-   If it's a method, but can also be used as a function, then it lives
with its object in S32, but has a cross-reference from S29


* Same question for BUILD and CREATE.
* What about metaclass methods, like .HOW.methods? Should they be 
covered in S29?


S32, according to above theory.

* Should there be a way to extract information about a Rat's 
numerator/denominator? What methods does a Rat have?


	Rat.avoid_trap(), Rat.eatcheese(), Rat.race(), etc.  Oh, wait, *that* 
kind of Rat :).


# The filetest operators. These are covered in S16, so maybe just mention 
them.


I should mention that these are now in IO.pod.


# true(), not(), also methods


On?

:)


-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI D G+ e++> h! y-

-END GEEK CODE BLOCK-