Ticket #1962 (new todo)

Opened 4 years ago

Last modified 3 years ago

:instanceof('Foo') is untested

Reported by: cotto Owned by:
Priority: normal Milestone:
Component: imcc Version: 2.11.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

imcc has a little-known sub modifier that causes a Sub to be created as an alternate PMC type. The one place it's documented, PDD19, contains the following description:

The C<:instanceof> pragma is an experimental pragma that creates a sub as a PMC type other than 'Sub'. However, as currently implemented it doesn't work well with C<:outer> or existing PMC types such as C<Closure>, C<Coroutine>, etc.

This needs to be added to DEPRECATED.pod as an officially experimental feature and, more importantly, needs to be tested.

Change History

Changed 4 years ago by whiteknight

First off, I can't imagine that this works at all. Looking through the code, it makes pervasive use of the Parrot_Sub_attributes* structure and the PMC_get_sub() macro. This is why derived types like Closure and Coroutine would probably not work well, and why other user-defined subclasses would stand no chance in hell of working.

Rather than making this feature work in IMCC/PIR at this point, I suggest we rip it out instead. We remove a feature that I suspect people aren't using now (because I suspect it's unusable), and we clean up IMCC just a tinsey-weensy little bit.

Changed 4 years ago by cotto

The reason this was discovered was because plobsing mentioned it in response to a question by jnthn about how to use a non-Sub invokable PMC in place of PIR-level subs without an hllmap. I also doubt that this would be a good solution for him in its current state, but it might be worth cleaning up depending on how important it is to his work.

Changed 4 years ago by jkeenan

  • component changed from none to imcc

Changed 3 years ago by jkeenan

whiteknight, cotto:

Do we know what we want to do here?

Changed 3 years ago by whiteknight

I strongly suggest we deprecate it. The current implementation through IMCC is inextricably linked to the internals of the Sub PMC, and changing that situation would almost be a larger task than removing and replacing IMCC completely.

It's worth noting that at the PBC level this should be very possible to do. However, IMCC makes it almost impossible to do as-is. An alternate assembler (or an alternate tool for generating PBC without PIR/IMCC) should give us new possibilities in this area.

I suggest we deprecate this feature, but keep it on the roadmap so we can keep it in mind when we work on new things.

Changed 3 years ago by pmichaud

On Mon, May 23, 2011 at 03:05:43PM -0000, Parrot wrote:
> #1962: :instanceof('Foo') is untested
> Comment(by whiteknight):
> 
>  I strongly suggest we deprecate it. The current implementation through
>  IMCC is inextricably linked to the internals of the Sub PMC, and changing
>  that situation would almost be a larger task than removing and replacing
>  IMCC completely.

FWIW, as far as I know :instanceof has always been listed as an 
"experimental feature" (pdd19), so deprecation might not even be
needed.  It was implemented as an early attempt at creating 
HLL-derived Sub types (needed by Rakudo) that quickly failed, but
the code was never removed.

>  It's worth noting that at the PBC level this should be very possible to
>  do. However, IMCC makes it almost impossible to do as-is. An alternate
>  assembler (or an alternate tool for generating PBC without PIR/IMCC)
>  should give us new possibilities in this area.

From Rakudo's perspective, the problem with :instanceof was that it
could only be used with PMCs (which had to exist and be loaded at
compilation time); it could not be used to create Subs that were 
defined in Parrot's Object/Class type hierarchy (e.g., as a HLL-derived
type).

Pm

Changed 3 years ago by cotto

I also don't think that even a deprecation notice is necessary for an explicitly experimental and fairly broken feature like this. As far as I'm concerned, a branch removing :instanceof could be merged into master today, if such a branch existed.

Note: See TracTickets for help on using tickets.