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

A specific wording in MAKE-ARRAY. #53

Open
jcguu95 opened this issue May 20, 2024 · 4 comments
Open

A specific wording in MAKE-ARRAY. #53

jcguu95 opened this issue May 20, 2024 · 4 comments

Comments

@jcguu95
Copy link

jcguu95 commented May 20, 2024

CLHS: Function MAKE-ARRAY says

If initial-element is not supplied, the consequences of later reading an uninitialized element of new-array are undefined unless either initial-contents is supplied or displaced-to is non-nil.

An element in the spec just means a lisp datum. It does not make sense to talk about whether an element is initialized or not. It is better, in my opinion, to instead say

If initial-element is not supplied, the consequences of later reading an uninitialized slot of new-array are undefined unless either initial-contents is supplied or displaced-to is non-nil.

But then we need to add a definition of a slot for an array somewhere else too.

@Bike
Copy link
Member

Bike commented May 22, 2024

Yeah, I wouldn't want to introduce new terminology, or rather to reuse "slot" to mean something other than a field in a structure or standard object. I'm not sure what wording would be better, though. "element" is already defined as "an object that is an element of the list or array that is the sequence" which is uh, a little recursive but still seems more appropriate than "slot".

The issue here is that it's more the position in the array that's "uninitialized", rather than there being some kind of distinguished uninitialized object. Maybe just dropping "uninitialized" would be good...?

@jcguu95
Copy link
Author

jcguu95 commented May 25, 2024

Dropping "uninitialized" is a bit restrictive too, because the user may write elements to such an array before reading it. In that case, reading the place afterward should not be undefined.

Actually, "slot" may not be a bad choice because its definition in the glossary doesn't restrict it to be used only in the context of standard objects:

slot n. a component of an object that can store a value. 

@robert-strandh
Copy link
Contributor

Given the glossary definition, I think "slot" is good. I use it myself to talk about the CAR and the CDR
of a CONS cell.

@jcguu95
Copy link
Author

jcguu95 commented May 26, 2024

Sure, hence I think the suggested edition in OP works.

If initial-element is not supplied, the consequences of later reading an uninitialized slot of new-array are undefined unless either initial-contents is supplied or displaced-to is non-nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants