metaeducation / rebol-issues

6 stars 1 forks source link

COPY/part on VECTOR is silently ignored #2399

Closed Oldes closed 4 years ago

Oldes commented 4 years ago

Currently it is not possible to copy just a part of the vector:

>> v: make vector! [integer! 32 [1 2 3]]
== make vector! [integer! 32 3 [
1 2 3
]]

>> copy/part v 2
== make vector! [integer! 32 3 [
1 2 3
]]

Expected result is make vector! [integer! 32 2 [1 2]] or at least error.

hostilefork commented 4 years ago

FYI, Ren-C catches a lot of these with unused declaration warnings. It does this by making macros for accessing the arguments of natives that declare constants. If those constants don't get referenced, you get a warning (which we turn into an error).

So if you have a native like my-native: native [x [integer!] /thing] you write something like:

REBNATIVE(my_native) {
    INCLUDE_PARAMS_OF_MY_NATIVE;

    if (Test_Integer(ARG(x))) {...}
   ...
}

And INCLUDE_PARAMS_OF_MY_NATIVE turns into something like:

static const int p_x = 1;
static const int p_thing = 2;

So it would notice you didn't say REF(thing), and warn you.


In other news, talks from the Philadelphia conference are now online:

https://2019.reb4.me/talks

As you've managed to learn a bit from working on the code over time, then perhaps my technical internals talk would make sense. It is subtitled: https://www.youtube.com/watch?v=6nsKTpArTCE.