World: r3wp
[!REBOL3-OLD1]
older newer | first last |
MichaelB 6-Apr-2006 [196] | this was a clear question imo :-) |
Gabriele 6-Apr-2006 [197] | everything else is unrelated. making closure the default would probably be a performance hit, and most people wouldn't really notice the difference (newbies don't expect closures, unless they come from lisp) |
Gregg 6-Apr-2006 [198] | Kind of what I was thinking. At the base level, for most users, it would be very nice to have default values, but not many folks will even know what closures *are*. |
MichaelB 6-Apr-2006 [199] | but I think they don't expect some of the side-effects which wouldn't be there with closures - at least I thought this until now |
Gabriele 6-Apr-2006 [200] | closure does not remove the side effects |
Gregg 6-Apr-2006 [201] | I don't like the extra block syntax, as that seems clunky. I don't care for Max's = syntax, because the = is just non-REBOlish in the context of setting a value. |
Gabriele 6-Apr-2006 [202] | closure allows you to do things that you can't do with funcs |
Maxim 6-Apr-2006 [203] | I'd prefer /option: 6 |
MichaelB 6-Apr-2006 [204] | I mean the examples from Ladislav when you use some of the capabilities of Rebol and get hit by not copying the context |
Maxim 6-Apr-2006 [205] | but is that possible in rebol? |
Gregg 6-Apr-2006 [206] | I think we need an extended func dialect. |
Maxim 6-Apr-2006 [207] | that's exactly what I mean. |
Gregg 6-Apr-2006 [208] | Yes, max, it is. |
Gabriele 6-Apr-2006 [209] | max, refinements are logic (none or true), they don't get a value |
MichaelB 6-Apr-2006 [210] | what about using a refinement in general for a optional intialization block ? |
Gregg 6-Apr-2006 [211] | Yes, I'm in agreement with you here Max, just not the = syntax. |
Maxim 6-Apr-2006 [212] | and depending on the needs of the func spec, it switched to closure |
Gabriele 6-Apr-2006 [213] | so you'd have /option val: 77, but this is a potential problem with return: in routines for e.g. |
Gregg 6-Apr-2006 [214] | Michael, I don't know if that's any better than an extra block, because you have to redundantly name the values. |
Maxim 6-Apr-2006 [215] | why use two words. |
Gabriele 6-Apr-2006 [216] | because you have refinements without args, with one arg, with two... and so on |
Gregg 6-Apr-2006 [217] | I think default values need to be specifiable like help strings are, but I haven't thought about the specific syntax yet. |
Gabriele 6-Apr-2006 [218] | /option, /option val, /option val1 val2 |
MichaelB 6-Apr-2006 [219] | what I think is that not everybody wants it (because could be optional) and a refinement would add it if wanted |
Maxim 6-Apr-2006 [220] | but the word is ALWAYS set, so in the context of its useage, its not optional. |
MichaelB 6-Apr-2006 [221] | I know there are drawbacks, but why not f: func/init [arg] [print arg] [arg: 2] and f: func [arg][print arg] |
Maxim 6-Apr-2006 [222] | cause the init block can be 2 pages further down the editor? ;-) |
MichaelB 6-Apr-2006 [223] | this breaks no code and uses the existing facilities yes that's the drawback |
Gregg 6-Apr-2006 [224] | I thought of that too, and came up with the same problem Max did. :-\ |
Maxim 6-Apr-2006 [225x2] | why not: f: func/init [arg] [[arg: 2] print arg] |
since its a dialect, func could just steal the first block... IF its a block | |
Gregg 6-Apr-2006 [227] | It could alsmost work with the existing syntax, in the type spec for an arg, because you can use example values in the spec for a type. |
Maxim 6-Apr-2006 [228] | it also allows local vars within face action :-) |
Gregg 6-Apr-2006 [229x3] | I don't like that Max, as it's totally different from the norm. |
There are problems if we use the existing syntax, so it's a question of how it would break things, and how many things would break. | |
e.g. you could use a paren! value, since they aren't evaluated in the spec, but that will break the .0000001% that use it today. | |
MichaelB 6-Apr-2006 [232x2] | f: func [arg (1)][print arg] |
? | |
Gregg 6-Apr-2006 [234] | e.g. fn: func [/opt n [(0) integer!] [print n] |
Maxim 6-Apr-2006 [235] | Gregg, you mean: f: func [/opt value [44 integer! none!]] [ print value] |
Gregg 6-Apr-2006 [236] | <he he> |
Maxim 6-Apr-2006 [237] | problem with the parens is that it gets in the way of compose |
Gregg 6-Apr-2006 [238] | Yes, that's the basic idea. I'd say it's rare for people to use literal values in specs, but they *can* do it today. And, yes, parens conflict with COMPOSE but, again, how much code COMPOSEs func specs? |
MichaelB 6-Apr-2006 [239] | why not allow all the datatypes in the brackets ?, so only the words are datatypes for the value and the rest could be an initialization value |
Gregg 6-Apr-2006 [240] | We can decide on any semantics, paren or any literal value, since it's really just a convention, like /local in the spec. |
MichaelB 6-Apr-2006 [241x4] | f: func [/opt n [#12 issue!][print "or something like that"] |
this looks pretty natural IMO ? | |
more than with paren! | |
there was a ] missing | |
Maxim 6-Apr-2006 [245] | hum... not sure about the # obscure, especially for newbies... depends on the datatype ##{a} , #'toto |
older newer | first last |