red / REP

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

WISH: allow set-words in Parse's SET & COPY #60

Open hiiamboris opened 4 years ago

hiiamboris commented 4 years ago

Allow: set word: rule copy word: rule as an alternative to: set word rule copy word rule so that word can be automatically localized by functions (else it's always a source of bugs and manual labor after every refactor)

greggirwin commented 4 years ago

If set-words have a different behavior, based on whether they follow a keyword, it seems like it will complicate parse, possibly leading to more bugs and work, offsetting gains from this feature. The alternative, to prep a func at the mezz level, adds to the number of func-making funcs we already have, and being very specialized. And it will have a long name if we specialize it to this purpose. :^\

Oldes commented 3 years ago

I don't think that allowing set-word! after set or copy command could complicate anything. And parse rules are really common source of leaked variables.

loziniak commented 3 years ago

s: 1 f: function[][parse ["abc"][set s string!]] f

I think current behavior is consistent with main Red syntax. I wouldn't expect s to not leak, because it's the same with normal set function:

>> s: 1 f: function[][set 's "xyz"] f
== "xyz"
>> s
== "xyz"
hiiamboris commented 3 years ago

@loziniak I hope you're not trying to say that you're a fan of the tedious procedure of manually detecting newly introduced words and extracting them out of the Parse rules (;

greggirwin commented 3 years ago

@hiiamboris I hope you're not trying to say that modal keyword one-shot relays are a free lunch. ;^)

hiiamboris commented 3 years ago

I accept a slight readability price, same as with set [x: y: z:] stuff (;