6

While working with the NCurses module I ran into some strange behavior that I've distilled in the repl as:

> my $c = ' '.ord
32
> $c.WHAT
(Int)
> my int32 $n = ' '.ord
32
> $n.WHAT
Bytecode validation error at offset 128, instruction 20:
operand type 32 does not match register type 24 for op getlex_ni in frame <unit>

> my int32 $m = 32
32
> $m.WHAT
Bytecode validation error at offset 128, instruction 20:
operand type 32 does not match register type 24 for op getlex_ni in frame <unit>

> my int32 $j = int32( 32 )
Cannot invoke this object (REPR: P6int; int32)
  in block <unit> at <unknown file> line 1

The problem is that wborder is defined with a signature of (NCurses::WINDOW, int32, int32, int32, int32, int32, int32, int32, int32 --> int32) but none of my attempts to come up with an int32 version of 32 have worked yet. I'm sure I'm missing something but I've no idea what.

hsmyers
  • 665
  • 7
  • 10
  • 2
    I see 4 apparently unrelated things. ➊ "Bytecode validation" error. This looks like a REPL bug. It applies without regard to `32`. For example, `my uint $a;` ends up with the same error. ➋ "Cannot invoke this object" error. This looks like a mistake you're making. You're invoking a call on an object that isn't callable. It applies to any such object. For example, `X()` ends up with a similar result because `X` is an `Exception`, and exceptions aren't callables. ➌ The number `32`. ➍ Discussion of `Ncurses` and `wborder`. I hear you're suggesting they're connected but I don't see the connection. – raiph Apr 08 '20 at 00:11
  • The connection is that I'm unable in actual code (not REPL) to use an actual 32 or any variation of the same as a parameter in the wborder call. Past experience in C led me to believe that it should accept char in those 6 positions. Something not possible with the existing declaration of int32 in Raku. I suppose a good start would be how to declare an in32 with a value of 32 and go from there. That is what I was doing in the REPL. – hsmyers Apr 08 '20 at 20:03
  • Others may see why you're explaining the connection between ➊, ➋, ➌, and ➍ by introducing *another* seemingly random [➎th element (about ➏ positions)](https://www.google.com/search?q=ncurses+%226+positions%22+wborder). But I'm not Bruce (Will Is Powerful). Maybe it's best if we both give up on riddles. ;) As you suggest, let's restart with how to declare an `int32` with a value of `32`. For a variable, it's `my int32 $foo = 32;`. Aiui this binds `$foo` so it corresponds to the integer `32` using an in-memory representation that's the underlying platform's C `int32_t` (*signed* integer) type. – raiph Apr 09 '20 at 07:30
  • Hi again. I hope you got through 2020 relatively unscathed, and wish you a better 2021. Were you using `EVAL`? I think it would likely be helpful to core devs if you could let them know in this ticket: [A straight EVAL bug involving accessing some types of natives from surrounding scope](https://github.com/rakudo/rakudo/issues/4161). If you *are*, well, it looks like that ticket explains your problem. – raiph Jan 12 '21 at 13:14

0 Answers0