REBOL3 tracker
  0.9.11 beta
Ticket #0001626 User: anonymous

Project:

Previous Next
TypeWish Statusreviewed Date30-Jun-2010 06:26
Versionalpha 99 CategoryNative Submitted byBrianH
PlatformAll Severityminor Prioritynormal

Summary Allow LENGTH? to take none as an argument, return none
Description The same argument that was put forth to make EMPTY? take the none argument could apply to LENGTH? as well: LENGTH? none could return none. The advantage would be to simplify the use of LENGTH? in code patterns like those shown below.

See http://www.rebol.net/r3blogs/0315.html for EMPTY? none and #1611 for INDEX? none.
Example code
; Desired behavior
>> index? none
== none


; Instead of this
b: either b: find series var [length? b] [default]

; I can then do this
b: any [length? find series var default]

Assigned ton/a Fixed in- Last Update30-Jun-2010 06:27


Comments
(0002409)
BrianH
30-Jun-2010 06:26

The disadvantage to this is that LENGTH? would occasionally return none, rather than always an integer (no, don't change the proposal to return anything other than none, it's the only sensible return value in this case). This means that code that needs to rely on integer data being there would have to check for that. This is not a big problem in R3 though because we can use ASSERT, or code like the EITHER example code.

So its either a function that forces you to use code like the EITHER pattern above all the time, or a function that only requires you to use it where appropriate but also requires you to *remember* this. The community's answer to the EMPTY? none question is probably a good guideline to follow: We prefer flexibility in R3, even if it can count as a gotcha, and can check things ourselves if we need to.

Date User Field Action Change
30-Jun-2010 06:27 BrianH Description Modified -
30-Jun-2010 06:27 BrianH Code Modified -
30-Jun-2010 06:27 BrianH Status Modified submitted => reviewed
30-Jun-2010 06:26 BrianH Comment : 0002409 Added -
30-Jun-2010 06:26 BrianH Ticket Added -