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

extend function should be improved/modified #2592

Open
Oldes opened this issue Mar 28, 2024 · 0 comments
Open

extend function should be improved/modified #2592

Oldes opened this issue Mar 28, 2024 · 0 comments
Labels
Red compatibility Issues and changes required for compatibility with Red language Type.wish

Comments

@Oldes
Copy link
Owner

Oldes commented Mar 28, 2024

Current extend function is defined as:

USAGE:
     EXTEND obj word val

DESCRIPTION:
     Extend an object, map, or block type with word and value pair.
     EXTEND is a function! value.

ARGUMENTS:
     obj           [object! map! block! paren!] Object to extend (modified).
     word          [any-word!]
     val           [any-type!]

While in Red language it is:

USAGE:
     EXTEND obj spec

DESCRIPTION: 
     Extend an object or map value with list of key and value pairs. 
     EXTEND is a native! value.

ARGUMENTS:
     obj          [object! map!] 
     spec         [block! hash! map!] 

REFINEMENTS:
     /case        => Use case-sensitive comparison.

And in Red it is possible to use it for example to merge two maps like:

>> extend #[a: 1 b: 2] #[b: 3 a: 1 c: 4]
== #[
    a: 1
    b: 3
    c: 4
]

I believe that being able to extend a value using a single pair of key and value like it is in Rebol now is also useful, but the key could be defined by refinement so default behaviour would be like in Red. The missing case-sensitivity is also an issue in Rebol!

@Oldes Oldes added Type.wish Red compatibility Issues and changes required for compatibility with Red language labels Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Red compatibility Issues and changes required for compatibility with Red language Type.wish
Projects
None yet
Development

No branches or pull requests

1 participant