REBOL3 tracker
  0.9.12 beta
Ticket #0002235 User: anonymous

Project:

Previous Next
Short URL: http://issue.cc/r3/2235
rss
TypeWish Statusdismissed Date2-Aug-2015 21:33
Versionr3 master CategoryEvaluation Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary Make a refinement's parameters default to excluding NONE!
Description Currently, a refinement's arguments will be NONE! if they are not supplied. So the following is legal:

foo: func [/bar param] [
if param [print "Got the param."]
]

It's more convenient than UNSET!, which is harder to handle. Were they UNSET!, it would mean that each attempt to use a refinement argument would first have to test the refinement itself:

foo: func [/bar param] [
if all [bar param] [print "Got the param."]
]

On the downside of using NONE!, it encourages a habit of potentially using the refinement arg as an indicator of whether the refinement *itself* had been provided. This overlooks the case of:

>> foo/bar none

(Though of course, the more problematic cases would look more like >> foo/bar some-function/with/lots [of 'args] {that returns none}, and the called function would be more complex as well.)

A simple compromise might be to remove NONE! from the types that a refinement argument will accept by default. This way, the average function may implicitly assume that any one of a refinement's arguments being none *means the refinement itself is not present*. The average case would likely benefit from being able to make such an assumption, as actually tolerating a NONE! argument to a refinement is likely rare.

Having a typeset meaning "anything that isn't unset" (e.g. VALID!) would make it easier to make an argument that would mimic the current behavior.
Example code

			

Assigned ton/a Fixed in- Last Update8-Jan-2016 00:32


Comments
(0004684)
Ladislav
7-Jan-2016 20:33

I do not like this. It introduces new special case not bringing sufficient benefit.
(0004686)
Ladislav
8-Jan-2016 00:32

The author changed his mind.

Date User Field Action Change
8-Jan-2016 00:32 ladislav Comment : 0004686 Added -
8-Jan-2016 00:32 ladislav Status Modified reviewed => dismissed
7-Jan-2016 20:53 ladislav Status Modified submitted => reviewed
7-Jan-2016 20:34 ladislav Comment : 0004684 Modified -
7-Jan-2016 20:33 ladislav Comment : 0004684 Added -
2-Aug-2015 21:37 Fork Description Modified -
2-Aug-2015 21:37 Fork Description Modified -
2-Aug-2015 21:33 Fork Ticket Added -