--------------------------------------it's like this-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk
Hello, i'm new to this list and to parrot programming, so i decided to
start with something simple. I implemented a String PMC that is pretty
much complete, it compiles, but i haven't tested it yet. It would be
great if someone had a look at it, and later when i write some tests
i'll check in a patch. The .pmc is attached.
> Hello, i'm new to this list and to parrot programming, so i decided to
> start with something simple. I implemented a String PMC that is pretty
> much complete, it compiles, but i haven't tested it yet. It would be
> great if someone had a look at it, and later when i write some tests
> i'll check in a patch. The .pmc is attached.
Looks quite good. Some notes:
- (you mentioned it) needs tests
- "extends mmd_default" isn't needed anymore, we do MMD anyway
- the patch duplicates a lot of PerlString's behaviour. So it would
probably be best to:
1) rename perlstring.pmc -> string.pmc
2) create: pmclass PerlString extends String
3) then duplicate the differing functions namely the set_<type>_native
funcs that morph a PerlString and don't in the String PMC.
leo
Honestly I'm tempted to throw away all the Perl* PMC classes and redo
them. Some of that code's quite old and a lot of things have changed since
we started with them, and I think we may do well to just start fresh.
If the string class is OK (I'm stuck with a dead machine and backup mail
access, so it's tough to get a good look at it) then let's put it in and
we can fix things up as we go.
Dan
--------------------------------------"it's like this"-------------------
Sorry this one sat so long. (Piers reminded me with the summary) I checked
in the PMC. Tests would be cool, to be sure. :)
Thanks much.
Dan
--------------------------------------"it's like this"-------------------
Actually Leo answered pretty quickly, and then you did too... but why
split hairs? :)
In the mean time i fixed some things that were wrong, added a few
functions and the tests. I found some weird things while doing this,
probably bugs. So here's the patch i promised.
The function string_make() in src/string.c reads in the documentation:
"the the string reperesentation will default to enum_stringrep_unknown".
This doesn't happen. I changed a line in classes/undef.pmc which used this.
As i understand, the default implementation for the function
is_equal_str() in a PMC is to fall back to is_equal(). This works OK.
But when i actually tried to implement is_equal_str(), it turns out the
return condition is used backwards (true means false :). BTW i didn't
find any documentation for is_equal_str(), it was generated by
genclass.pl. I commented out my implementation of is_equal_str() and the
tests pass now... it's still there if anyone wants to play with it.
Now back to the String class. I should say that much of the code was
inspired by PerlString, and the tests, well, i just took them from
perlstring.t. There's still some original code there tough :)
Leo suggested to subclass PerlString from String, but it's already
subclassed from PerlScalar, do PMC's have multiple inheritance?
And a noob question: what does the $Id: line at the top of each file do?
Is it generated or do I have to uptade it myself?
alexm
Can you please rediff string.pmc - it is in the CVS already, but you did
provide the whole file. I've checked in the other changes though.
(3 tests failing - likely becausof missing pieces from string.pmc)
> The function string_make() in src/string.c reads in the documentation:
> "the the string reperesentation will default to enum_stringrep_unknown".
A new string will get the default / global settings from the
interpreter, which we don't have yet.
> As i understand, the default implementation for the function
> is_equal_str() in a PMC is to fall back to is_equal(). This works OK.
is_equal_str() forces both sides being strings. This is the default for
strings is_equal, so they are the same.
> But when i actually tried to implement is_equal_str(), it turns out the
> return condition is used backwards (true means false :).
Its modeled like strcmp().
> Now back to the String class. I should say that much of the code was
> inspired by PerlString, and the tests, well, i just took them from
> perlstring.t. There's still some original code there tough :)
>
> Leo suggested to subclass PerlString from String, but it's already
> subclassed from PerlScalar, do PMC's have multiple inheritance?
Not really albeit OrderedHash does it. But for PerlString its totally ok
to inherit from String only. Most of the functionality is the same.
> And a noob question: what does the $Id: line at the top of each file do?
> Is it generated or do I have to uptade it myself?
Its generated by CVS. The variable $Id$ gets expanded to what you see
there -- so no.
> alexm
Thanks,
leo
> On Sun, 20 Jun 2004, Ion Alexandru Morega wrote:
>
>> Dan Sugalski wrote:
>> > I checked in more of PDD 17, detailing parrot's base types. Some of
>> > those types definitely don't exist (like, say, the string and bignum
>> > type...) and could definitely use implementing. Should be fairly
>> > straightforward, and would be a good way to get up to speed on writing
>> > PMC classes.
>>
>> Hello, i'm new to this list and to parrot programming, so i decided to
>> start with something simple. I implemented a String PMC that is pretty
>> much complete, it compiles, but i haven't tested it yet. It would be
>> great if someone had a look at it, and later when i write some tests
>> i'll check in a patch. The .pmc is attached.
>
> Sorry this one sat so long. (Piers reminded me with the summary)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It worked then --------------------------------'
> Dan Sugalski <d...@sidhe.org> writes:
>
> > Sorry this one sat so long. (Piers reminded me with the summary)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> It worked then --------------------------------'
And not for the first time either. :)