Opened 7 years ago

Closed 6 years ago

#49 closed defect (wontfix)

undefined values

Reported by: medernac Owned by: medernac
Priority: minor Milestone:
Component: WG1 - Core Keywords:


There are code which uses tricks to report <undefined> values, like this one:
(if #f #f)

Some cleaner mechanism has to be proposed for returning <undefined> values.

Change History (4)

comment:1 Changed 7 years ago by medernac

  • Owner changed from alexshinn to medernac
  • Status changed from new to assigned

Let it be clearer:

I know there are a proposed mechanism in R6RS with exceptions, however there are cases where a specific "undefined" value are to be returned.
For instance when an empty vector is created (make-vector k), depending on the implementation different Schemes give different values inside the vector cells, this is dangerous if these values are used and cannot be identified as "undefined" values.

Question: Is there a difference between unbound variable and a variable with undefined value ? to me yes, because the unbound variable is not allocated, whereas a variable with undefined value is allocated.

comment:2 Changed 7 years ago by arcfide

Yes, there is a difference, but I think this is talking specifically about unspecified values. I would say that the VOID thunk is as good as any for a procedure that explicitly returns an unspecified value. This is different than something like what is filled in a vector. You don't want to force vectors to contain any sort of data, because this could be a very serious performance problem. It's much better to let them be filled with whatever the implementation wants to fill it at the time. The 2-argument version of that function should be used when you want to guarantee something about the contents: (make-vector k #f). It's not dangerous to have these values be unreliable, because they'll still be something, even if you can't predict what they will be. It will not cause Scheme to crash, and it should not. And yes, there is a big difference between an undefined or unspecified value and an unbound variable. A variable that is unbound has a specific name, but no bindings, whereas an unspecified value may have a specific single representation, but it probably is bound to very few names, or locations, if any.

comment:3 Changed 7 years ago by medernac

I agree that the best would be to standardize "void", at least I known that Chicken, Gambit, Guile and STklos implementations have it.

Then we must make sure that forms returning unspecified/undefined values returns (void).

comment:4 Changed 6 years ago by cowan

  • Resolution set to wontfix
  • Status changed from assigned to closed

WG1 voted not to have an undefined-value API.

Note: See TracTickets for help on using tickets.