egallesio / STklos

STklos Scheme
http://stklos.net
GNU General Public License v2.0
70 stars 17 forks source link

Describe uvectors #496

Closed jpellegrini closed 1 year ago

jpellegrini commented 1 year ago

But we still don't give their length in the description.

@egallesio -- the %uvector-length procedure takes an integer (the tip) and a uvector. For describe, it would make sense to have a wrapper that does not need the tip, so we can also report the length.

What do you think is better?

  1. Add a new procedure, like %general-uvector-length that only takes a uvector? Something that would only do

    return MAKE_INT(UVECTOR_SIZE(v));

    and just return the length?

  2. Change %uvector-length to subr12, so it can be called with args (tip uvec) or (uvec)

  3. Write a general API for uvectors that do not require the user to include the uvector type? That would include uvector-length, uvector-{ref,set}, uvector->list, uvector?... (The last one really makes sense - -SRFI 4 does not offer a general uvector? predicate... See that the code in this PR uses is-a?)

  4. not report the length

  5. Some other possibility?

egallesio commented 1 year ago

Hello @jpellegrini, Sorry for the long delay. But finally here it is. The commit is a mix of point 2 and 3.