Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

obj.class returning unexpected values #10

Open
treed opened this Issue · 8 comments

2 participants

@treed

.class on Proc is not Proc. It's probably CardinalProc, but I haven't looked. Unsure how to go about this one. (Shows up in proc.t.)

@treed

This is also evident in range.t

@treed

Okay. I've done some research now. Took me some time because I had to fix a bug first to even try this. .class on a Proc is "Proc()", but only if you declare it as a proc. A bare proc (literal?) is a Sub, which has no .class.

A Range is coming across as CardinalRange, though. Unsure whether the better way to fix this is to simply rename the class, or get .class to lie.

@tene
Collaborator

1) hll_map Sub
2) Now that Cardinal is in its own .HLL, you should be able to get rid of all the crap CardinalFoo names, because no more namespace conflicts with core parrot types.

@treed

The last issue is that it'll be appending () to the names, which I think is solveable by adding to_s to the Metaclass that other metaclasses inherit from. Then having Object.class use that.

@treed

Okay, wow. hll_mapping Sub resulted in cardinal throwing sigbus for any attempt at execution. Did I do something particularly weird here?

diff --git a/src/classes/Proc.pir b/src/classes/Proc.pir
index 0073b1f..5034529 100644
--- a/src/classes/Proc.pir
+++ b/src/classes/Proc.pir
@@ -20,9 +20,14 @@ Perform initializations and create the Proc class
 .namespace ['Proc']

 .sub 'onload' :anon :init :load
-    .local pmc cardinalmeta
+    .local pmc cardinalmeta, core_type, hll_type, interp
     $P0 = get_hll_global ['CardinalObject'], '!CARDINALMETA'
     cardinalmeta = $P0.'new_class'('Proc', 'parent'=>'CardinalObject', 'attr'=>'!block')
+
+    core_type = get_class 'Sub'
+    hll_type = get_class 'Proc'
+    interp = getinterp
+    interp.'hll_map'(core_type, hll_type)
 .end

 .sub 'get_bool' :vtable
@treed

Could be that Proc doesn't actually subclass Sub, but it still shouldn't be crashing.

@treed

Issue #27 concerns a rewrite of Proc which should help with this.

@treed

Alright, so here's the updated status:

Waiting on #27 for the Proc rewrite.
Waiting on #34 for the s/CardinalFoo/Foo/
Waiting on #35 for the "Foo()" to "Foo" thing.

Once those are done, this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.