Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WISH: compact construction syntax for vector types #2397

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Closed

WISH: compact construction syntax for vector types #2397

Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Labels
enhancement New feature or request Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written Type.wish

Comments

@Siskin-Bot
Copy link
Collaborator

Submitted by: Oldes

As we don't have any syntax for vector and its variants, I think it would be nice to enhance construction syntax a little bit, to support short vector variant creation.

For example:

>> #[ui8! 3]
== make vector! [unsigned integer! 8 3 [0 0 0]]
>> #[si16! [1 2 3]]
== make vector! [integer! 16 3 [1 2 3]]

Supported numeric types could be:

si8!
si16!
si32!
si64!

ui8!
ui16!
ui32!
ui64!

f32!
f64!

Imported from: metaeducation#2396

Comments:

Oldes added a commit to Oldes/Rebol3 that referenced this issue on Jan 29, 2020:
FEAT: VECTOR compact construction


Oldes added a commit to Oldes/Rebol3 that referenced this issue on Jan 29, 2020:
TEST: using short vector construction in a part of the vector tests


Oldes added a commit to Oldes/Rebol3 that referenced this issue on Jan 29, 2020:
TEST: a few more vector tests (using semi-compact construction)


Jankom commented on Jan 29, 2020:

Can I ask what you use vectors for in Rebol? Absolutely not that I think they aren't usefull, but I haven't thought of using them so far with Rebol and am just interested?

Does r3 have special block types like #[ ] ?

The solution of just having a function like a "vector" function like vector 'ui32 [ 1 2 3 ] is not OK because you want to create them directly from loader, not a block that is then loaded into vector at runtime?


Oldes commented on Jan 30, 2020:

At this moment I'm using vectors for sound processing and before I used them in graphics too.
#[] is construction syntax... usually used with save/all and mold/all to save data in serialized format without losing index.

>> mold next "123"
== {"23"}

>> mold/all next "123"
== {#[string! "123" 2]}

Oldes commented on Jan 30, 2020:

I know, that it is just a cosmetic thing, but why not to have it, when it was so cheap to add. My goal is to do 3D from Rebol one day, and I think, that code:

cam-Position: #[f32! [4.0 3.0 3.0]] ;Camera is at (4,3,3), in World Space
cam-Target:   #[f32! [0.0 0.0 0.0]] ;and looks at the origin
cam-Head:     #[f32! [0.0 1.0 0.0]] ;Head is up

looks better than:

cam-Position: make vector! [decimal! 32 [4.0 3.0 3.0]] ;Camera is at (4,3,3), in World Space
cam-Target:   make vector! [decimal! 32 [0.0 0.0 0.0]] ;and looks at the origin
cam-Head:     make vector! [decimal! 32 [0.0 1.0 0.0]] ;Head is up

Of course I can use helper functions.


@Siskin-Bot Siskin-Bot added the Oldes.resolved Bugs/wishes with Oldes' fixes/features label Feb 15, 2020
@Oldes Oldes closed this as completed Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written Type.wish
Projects
None yet
Development

No branches or pull requests

2 participants