Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #32645] [TODO] Generic PMC type info

4 views
Skip to first unread message

Will Coleda

unread,
Nov 26, 2004, 6:50:15 PM11/26/04
to bugs-bi...@rt.perl.org
# New Ticket Created by Will Coleda
# Please include the string: [perl #32645]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=32645 >


Based on a conversation with Dan in IRC, it should be possible to interrogate PMCs about their generic type.

For example, tcl's [array exists varName] returns true if the variable is defined /and/ is an array variable (in perl-speak, a hash).

But, there's no easy way to ask a PMC, "are you hashlike?". So, for now, I have code like:

isnull the_array, array_no
typeof $I0, the_array
if $I0 != TclArray goto array_no
array_yes:

Which is fine if I'm self-contained, but not very nice for cross-language support.

Dan says:

09:37 <@Dan> Hrm. Post a bug to the list. We should collect up a list
of
properties that should be easily queryable
09:37 <@Dan> integer/float/string/invokable/hashlike/arraylike
09:37 <@Dan> Maybe some others too


Leopold Toetsch

unread,
Nov 27, 2004, 1:52:00 AM11/27/04
to perl6-i...@perl.org
Will Coleda <parrotbug...@parrotcode.org> wrote:

> Based on a conversation with Dan in IRC, it should be possible to
> interrogate PMCs about their generic type.

> For example, tcl's [array exists varName] returns true if the variable
> is defined /and/ is an array variable (in perl-speak, a hash).

> But, there's no easy way to ask a PMC, "are you hashlike?".

Ha?

$ cat does.imc
.sub main @MAIN
$P0 = new Array
$I0 = does $P0, "array"
print $I0
$P1 = new PerlHash
$I0 = does $P1, "hash"
print $I0
print "\n"
$I0 = does $P1, "array"
print $I0
$I0 = does $P0, "hash"
print $I0
print "\n"
.end

$ ./parrot does.imc
11
00

leo

William Coleda

unread,
Nov 27, 2004, 9:49:53 AM11/27/04
to parrotbug...@parrotcode.org
Whoops. Perhaps Dan was merely stringing me along. =-)

Closing call.

0 new messages