Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALL [()] should have the same result as ALL [] #850

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 2 comments
Closed

ALL [()] should have the same result as ALL [] #850

Siskin-Bot opened this issue Feb 15, 2020 · 2 comments

Comments

@Siskin-Bot
Copy link
Collaborator

Submitted by: Ladislav

Checked #564: "ANY and ALL are primarily used as control structures. As such, it might be good for unset! values to be skipped by both ANY and ALL, like noops." If that is what we want, then

all [()] 

has to yield the same result as

all [] 

i.e. True, not #[unset!], etc.

equal? type? all [()] type? all [] ; yields False

Imported from: CureCode [ Version: alpha 54 Type: Bug Platform: All Category: n/a Reproduce: Always Fixed-in:none ]
Imported from: metaeducation#850

Comments:

Rebolbot commented on May 26, 2009:

Submitted by: BrianH

Good point, even though #[unset!] counts as true for control functions. Ticket changed to reflect the new request - just put a copy of your comment in there and tweaked the code.


Rebolbot commented on May 27, 2009:

Submitted by: Ladislav

I guess that it is possible to change the implementation of All so that #[unset!] is completely ignored, i.e., that

all [1 ()]

would yield 1, etc.


Rebolbot mentioned this issue on Jan 12, 2016:
Make ALL completely ignore UNSET! values


Rebolbot mentioned this issue on Jan 22, 2016:
[Epic] Backwards-incompatible API changes, for the greater good


Rebolbot added the Type.bug on Jan 12, 2016


Hostilefork added on Jun 13, 2018


Hostilefork commented on Jun 13, 2018:

This is clearly a point of confusion overall. I'll note that at time of writing, Red says:

>> all []
== none

>> all [()]
;-- no result

I guess that it is possible to change the implementation of All so that #[unset!] is completely ignored, i.e., that

all [1 ()]

Originally in Ren-C this was the implementation choice, because NULLs were "neither true nor false". This was a feature inspired by the desire to have ways to print output in the middle of an ANY or an ALL without disturbing the logic of it (picking either true or false would disturb one or the other). Hence NULLs would "opt out" of ANY and ALL.

Beyond having functions that would always opt-out, this feature speculated a little bit on being a kind of arbitrary tristate...where one might have a routine that could return a truthy value, a falsey value, or a NULL... thus either voting yes or no or abstaining. Building in such a feature is kind of random, and actually got in the way of much more mainstream needs of the "non-value" status of NULL.

But when "invisibles" came on the scene, they provided new features such as ELIDE to take care of most opting-out scenarios. And it really just began to make more and more sense to consider NULLs as falsey, which Ren-C now does:

metaeducation/ren-c#816

And all failed ALLs return null as well, not blank. So all [()] = (), basically...and x: all [false] will error, because there is no actual value to be assigned. If this is okay, you have to say so explicitly with x: try all [...]

In light of this, it makes perfect sense that all [] should also be null...which offers the consistency sought in this issue. So the previous synthesis of a truthy value is now removed:

metaeducation/ren-c@e8ab17a

Clearly no one would be writing all [] in source anyway, so this would only come up in generated or composed code. That code could solve this problem by putting whatever result it wanted in at the tail, such as all [... true], or use one of the many null-handling operations in Ren-C, e.g. all [...] else [...]


Hostilefork mentioned this issue on Jun 13, 2018:
ANY and ALL treat unset! as a value, not as none! or false!


Oldes added a commit to Oldes/Rebol3 that referenced this issue on Oct 7, 2018:
FEAT: making UNSET! as a conditionally "TRUTHY"


Hostilefork commented on Oct 23, 2018:

In Ren-C, further changes have affected this issue...because GROUP! no longer synthesizes any values...it only groups them.

>> 1 + 2 ()
== 3

Hence ALL does not have the opportunity to differentiate all [()] and all []...it is running the evaluator and deferring to it, and in doing so sees nothing. It would be the same as all [comment "Hi"] as well.

There's no special code in ALL needed for this transparency--it just emerges from the new properties of GROUP!.

https://forum.rebol.info/t/what-to-do-about-do-and/772


Hostilefork added the Ren.resolved on Oct 23, 2018


@Oldes
Copy link
Owner

Oldes commented Apr 14, 2020

Current behaviour is:

>> equal? if all [][1] if all [()][1]
== true

@Oldes Oldes closed this as completed Apr 14, 2020
@Oldes Oldes added Red compatibility Issues and changes required for compatibility with Red language and removed Red compatibility Issues and changes required for compatibility with Red language labels Apr 14, 2020
@Oldes Oldes reopened this Feb 6, 2024
@Oldes
Copy link
Owner

Oldes commented Feb 6, 2024

Now it is:

 none? any []
 none? any [()]
   1 = any [() 1]
   1 = all [1 ()]
unset? all []
unset? all [()]

Oldes added a commit to Oldes/Rebol3 that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants