red / REP

Red Enhancement Process
BSD 3-Clause "New" or "Revised" License
11 stars 4 forks source link

WISH: make map! <object> #165

Open hiiamboris opened 4 months ago

hiiamboris commented 4 months ago

While I agree with https://github.com/red/red/issues/2338 reasoning that object->map conversion is dangerous, at the same time from time to time I have to go through the odd object->block->map route (which is also lossy atm), and I remember it was being requested by others.

The use case rests on these issues:

So by writing

map: to map! to block! object [
    func1: func [args] [body...]
    ...
]

I can create a set of functions (or objects with functions) that is safely extensible at runtime.

I've counted 8 occurrences of that in my code, and there's also sometimes a trick to make the spec more human-readable (but it's of low importance): to map! to [] object [dec: sci: pct: none] instead of: #[dec: #[none] sci: #[none] pct: #[none]]

Of course if we plan to make objects extensible, this would obsolete this wish.