REBOL3 tracker
  0.9.12 beta
Ticket #0002107 User: anonymous

Project:



rss
TypeWish Statussubmitted Date20-Feb-2014 05:10
Versionr3 master CategoryMezzanine Submitted byBrianH
PlatformAll Severityminor Prioritynormal

Summary Move FUNCTION and CLOSURE /with and /extern options into the spec block
Description FUNCTION and CLOSURE both have /with and /extern options, which take arguments. Those arguments end up appearing after the code block, which is often quite far away from the beginning of the function definition. Both these options affect the function's semantics quite a bit, so if either are specified you have to go down to read the argument, then back up to read the start of the code.

This could be improved if we moved both of the options into the spec block, as with: and external: clauses.

The with: would be followed by an expression that would need to be evaluated with DO/next, which would result in the value we want to process. We have to have an expression here because object values tent to be the result of one.

The external: would be followed by a list of words, ending at the end of the block or the first element not of the word! type - or we could require that the words go in a nested block, for clarity and speed of processing. It wouldn't be an expression, this value only works when it's as static as the code block.

These clauses would be removed from the spec before collecting the locals, and before passing to MAKE.

This proposal would make function and closure specs easier to read. We probably want to enhance that by removing the /with and /extern options as well.

We should consider whether multiple clauses of the same type should be an error, or if they should all be applied. There is a sensible meaning for them to all be applied, if that's the way we decide to go.

(Requested by Fork in SO chat.)
Example code
; Before
a: function/with [x y z] [some code] [a: 1]
; After
a: function [x y z with: [a: 1]] [some code]

; Before
a: function/with [x y z] [some code] self
; After
a: function [x y z with: self] [some code]

; Before
a: function/extern [x y z] [some code] [a b]
; After
a: function [x y z external: a b] [some code]
; or maybe
a: function [x y z external: [a b]] [some code]

Assigned ton/a Fixed in- Last Update5-Mar-2014 11:19


Comments

Date User Field Action Change
5-Mar-2014 11:19 BrianH Description Modified -
20-Feb-2014 05:13 BrianH Code Modified -
20-Feb-2014 05:12 BrianH Description Modified -
20-Feb-2014 05:12 BrianH Code Modified -
20-Feb-2014 05:10 BrianH Ticket Added -