Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Complex now holds two native nums
allso bumps NQP_REVISION, and adds a note to NOMMAP about segfaulting
autogenerated accessors
  • Loading branch information
moritz committed Jul 1, 2011
1 parent 0feaed3 commit 7ea50ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NOMMAP.markdown
Expand Up @@ -19,6 +19,8 @@ Things that aren't blockers but might be worth knowing about:
* userspace code can't add new multis of existing operators
(e.g., multi postfix<++>(MyType $x) { ... } )
(known - multis in nested lexical scopes in general just NYI - jnthn)
* 'has num $.attr' segfaults on access to .attr, because it uses the PMC form
of get_attribute

## Lexical Multi-Part names
For my X::Base { ... }, my Foo::Bar { ... } etc. The our-scoped ones work.
Expand Down
15 changes: 10 additions & 5 deletions src/core/Complex.pm
@@ -1,15 +1,20 @@
# XXX should also be Cool
my class Complex is Numeric {
# TODO: type as Num?
has $.re;
has $.im;
has num $!re;
has num $!im;

# XXX should not be needed, but currently segfaults
# with the autogenerated accessors (has num $.re)
method re() { $!re }
method im() { $!im }

proto method new(|$) { * }
multi method new(Real \$re, Real \$im) {
my $new = self.CREATE;
$new.BUILD($re, $im);
$new.BUILD($re.Num, $im.Num);
$new;
}
method BUILD(Real \$re, Real \$im) {
method BUILD(Num \$re, Num \$im) {
$!re = $re;
$!im = $im;
}
Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
@@ -1 +1 @@
2011.06-13-g6d9b526
2011.06-15-gef8b5d3

0 comments on commit 7ea50ce

Please sign in to comment.