Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Some tasks for the interested

29 views
Skip to first unread message

Leopold Toetsch

unread,
Jun 27, 2004, 12:18:50 PM6/27/04
to Perl 6 Internals
1) Python has a complex builtin class. So we'll need one too.
* Create a complex PMC.
* Parse complex constants '4j'
* Put these constants into the PBC?

2) We need a *array.sort (NCI) method(s)
That's kind of a PITA: The fixed/resizable array PMCs don't
have push/pop/unshift/shift ..., and shift/unshift will not
really fly for these classes, but they have simple linear
memory. The list.c based arrays OTOH have memory splitted
into chunks, which complicates sorting.
The compare function of sort must be overridable with PASM code.

I hope that's all finished, when I'm back from Germany on Thursday:)

leo

Jonathan Worthington

unread,
Jun 27, 2004, 2:30:05 PM6/27/04
to Perl 6 Internals
"Leopold Toetsch" <l...@toetsch.at> wrote:
> 1) Python has a complex builtin class. So we'll need one too.
> * Create a complex PMC.
> * Parse complex constants '4j'
j? I've always used i as the imaginary unit, though I believe j is used
more in engineering fields ('cus they use i for current, or so I've heard).
i for "imaginary" would make more sense to me, but that's just me. ;-)

Jonathan


Ion Alexandru Morega

unread,
Jun 27, 2004, 6:57:44 PM6/27/04
to perl6-i...@perl.org

IMO the parser should understand both. And if noone else desperately
wants to do it i'll be glad to help.

Dan Sugalski

unread,
Jun 28, 2004, 10:15:46 AM6/28/04
to Ion Alexandru Morega, perl6-i...@perl.org

Cool, go for it. I'd think that for the set_(integer|number) vtable slots
we'd set the real part and make the imaginary part 0, while the string
version'd look for the "x + yi" version.

I think for now both i and j are fine for the imaginary part.

And I'm now thinking that we want to do mmd for assignment. Dammit. :(

Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Ion Alexandru Morega

unread,
Jun 28, 2004, 12:51:41 PM6/28/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski wrote:

> <>Cool, go for it. I'd think that for the set_(integer|number) vtable
> slots
> we'd set the real part and make the imaginary part 0, while the string
> version'd look for the "x + yi" version.

And have set_num_keyed set the real and the imaginary part (indexed as
strings, say "real" and "imag") and maybe change the modulus and the
argument independently. Also get_num_keyed will return the real part,
imaginary part, modulus and argument (and maybe cache the last two).

>And I'm now thinking that we want to do mmd for assignment. Dammit. :(
>
>

You'll have to explain that to me. :)

I've done some more work on the String PMC and its tests, I'll send a
patch later today.

> Dan
>
>
alexm

Leopold Toetsch

unread,
Jul 1, 2004, 2:42:30 AM7/1/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

> And I'm now thinking that we want to do mmd for assignment. Dammit. :(

Don't think so. We need, ehem, probably, set_complex, get_complex and so
on vtables. Complex is a basic type like integer, number, or bignum.

def main():
i = complex(2 + 1j)
print i

>>> dis(im.main)
2 0 LOAD_GLOBAL 0 (complex)
3 LOAD_CONST 1 (2)
6 LOAD_CONST 2 (1j)
9 BINARY_ADD
10 CALL_FUNCTION 1

MMD does the math then automatically, if the proper slots are filled.
Happily, the tests don't use complex very often. It's just:

,--[ The Pie-thon README.txt ]-----------------------------------------
| The benchmark here is intended to make Dan Sugalski's life difficult:
`----------------------------------------------------------------------

> Dan

leo

Dan Sugalski

unread,
Jul 6, 2004, 10:58:16 AM7/6/04
to l...@toetsch.at, perl6-i...@perl.org
At 8:42 AM +0200 7/1/04, Leopold Toetsch wrote:
>Dan Sugalski <d...@sidhe.org> wrote:
>
>> And I'm now thinking that we want to do mmd for assignment. Dammit. :(
>
>Don't think so. We need, ehem, probably, set_complex, get_complex and so
>on vtables. Complex is a basic type like integer, number, or bignum.

Probably. More a set_imaginary than set_compex, though. I don't think
that's needed as such for the benchmark, though. (And should it take
a BIGNUM or a NUMVAL?)

>def main():
> i = complex(2 + 1j)
> print i
>
>>>> dis(im.main)
> 2 0 LOAD_GLOBAL 0 (complex)
> 3 LOAD_CONST 1 (2)
> 6 LOAD_CONST 2 (1j)
> 9 BINARY_ADD
> 10 CALL_FUNCTION 1
>
>MMD does the math then automatically, if the proper slots are filled.

Yeah. In this case, if the 1j constant is a PMC, it ought be a
Complex PMC (or an Imaginary one) and then MMD should work out fine
without needing slots.

>Happily, the tests don't use complex very often. It's just:
>
>,--[ The Pie-thon README.txt ]-----------------------------------------
>| The benchmark here is intended to make Dan Sugalski's life difficult:
>`----------------------------------------------------------------------

Ah, yeah, that's Guido--ever thoughtful. :)
--
Dan

--------------------------------------it's like this-------------------

Leopold Toetsch

unread,
Jul 6, 2004, 11:17:19 AM7/6/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski wrote:
> At 8:42 AM +0200 7/1/04, Leopold Toetsch wrote:

> Probably. More a set_imaginary than set_compex, though. I don't think
> that's needed as such for the benchmark, though. (And should it take a
> BIGNUM or a NUMVAL?)

NUMVAL. But for now, I'm using strings, which works fine. Too less time
to implement that whole stuff.

leo

0 new messages