Printing from inside a C function with rebElide

Not sure this is the right place for this question.

To help myself with the workings of the GTK3 binding, I want to put in some printing statements showing the values of certain items.

I have this working code where I want to print the return value of the C function from within another function

unsigned int result = gtk_main_level();
REBVAL *text = rebValue("{}");
rebElide("append", text , rebI(result));
rebElide("print {after append}");
rebElide("print", text);
rebRelease(text);

The thing is I was expecting the fifth line replaced by:

rebElide("print {The value of gtk_main_level equals", text, "}");

also to work, but this results in the exiting of the program with a segfault.
Why is this?

I managed to reform this into:

rebElide("print spaced [{The value of gtk_main_level equals}", rebI(level), "{ high!}]");

which works allright.

But I think the case sensitivity is really getting annoying:

(i) Info: use WHY for error information
** Script Error: SPACED is ~unset~ (use GET/ANY to GET voids)
** Where: gtk-main console
** Near: [print SPACED ** ["main level is" 1 "HIGH"]]

Looks like you got it. Though the SPACED is not necessary there (PRINT will use SPACED by default).

(See source code for PRINT if you are curious about it.)

I'm kind of reaching the inevitable conclusion that you need to be able to choose case sensitivity vs. not, perhaps on a module-by-module basis.

Because I can see instances where needing the capital letters for meanings is important, and cases where it is not.

Certainly dialects need to be able to choose if case means something. So I think if a general mechanic of choice is incorporated into the main language that's the right answer.

1 Like

wELL i DO HAPPEN TO LEAVE ON THE cAPS-lOCK KEY A LOT :slight_smile: