Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Object PMC class can't be instantiated #1010

Open
Util opened this Issue · 0 comments

2 participants

@Util
Owner

Reported by: zefram@fysh.org

PDD 15 gives the impression that Object is a standard superclass for user classes, to the extent that one might expect user classes to have Object as a parent by default. In fact Object doesn't enter the inheritance hierarchy unless it is explicitly added, and furthermore inheriting from it actually makes a class unusable:

$ cat t49.pir 
.sub main :main
       $P0 = subclass "Object", "Foo"
       $P1 = new $P0
.end
$ ./parrot t49.pir 
Object must be created by a class.
current instr.: 'main' pc 4 (t49.pir:3)

Object cripples the init vtable methods, apparently with the intent that classes will create object PMCs by other means. But the instantiate vtable method of Class just uses the ordinary PMC creation mechanism, running straight into the crippled initialisation. $P0."new"() isn't any better, as the named method on Class is just a wrapper for the instantiate vtable method.

If the class is defined without mentioning Object as a parent ('newclass "Foo"' instead of 'subclass "Object", "Foo"') then object creation works fine. Evidently the object doesn't get the Object vtable in this case, but I think it must be getting the Object PMC layout.

-zefram

Summary of my parrot 5.7.0 configuration:
 configdate='Sat Oct  5 12:42:43 2013 GMT'
 Platform:
   osname=linux, archname=x86_64-linux-gnu-thread-multi
   perl=/usr/bin/perl
@rurban rurban referenced this issue from a commit
@rurban rurban [test] add testcase for GH #1010 subclass from Object
we should be able to specify inheritance from Object explcitly
bdc36c2
@rurban rurban self-assigned this
@rurban rurban referenced this issue from a commit
@rurban rurban [test] add TODO testcase for GH #1010 subclass from Object
we should be able to specify inheritance from Object explicitly
9c4f59d
@rurban rurban added this to the 7.0.0 milestone
@rurban rurban modified the milestone: 7.1.0, 7.0.0
@rurban rurban modified the milestone: 7.3.0, 7.1.0
@rurban rurban modified the milestone: 7.4.0, 7.3.0
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.