Added object() in cheat sheet for snapshot#159
Conversation
jordanbrown0
left a comment
There was a problem hiding this comment.
Basically good. Two requested changes (lower-case anchor for has_key(), don't move section boundary), one recommendation (re-order the object() variants), and a couple of points for discussion that don't require action now.
| </section> | ||
| <section> |
There was a problem hiding this comment.
Undo: I wouldn't make this particular change, especially as part of this project. Having "Functions" be at the top of a column seems right; burying it under "Other" seems wrong. On the other hand, I don't know why "Type test functions" is before Functions; I'd move it over to after "Functions" or after "Mathematical". But again, Not This Project.
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(…,object,…);</a></code></dt> | ||
| <dd> copy</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(…,name=value,…);</a></code></dt> | ||
| <dd> assign/override</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(…,[…,["name"],…],…);</a></code></dt> | ||
| <dd> remove name</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(…,[…,["name",value],…],…);</a></code></dt> | ||
| <dd> add name=value</dd> |
There was a problem hiding this comment.
Recommendation: I would order these as
- name=value
- object
- [[name,value]]
- [[name]]
because I think name=value is the most likely variant.
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(…,object,…);</a></code></dt> | ||
| <dd> copy</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(…,name=value,…);</a></code></dt> | ||
| <dd> assign/override</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(…,[…,["name"],…],…);</a></code></dt> | ||
| <dd> remove name</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(…,[…,["name",value],…],…);</a></code></dt> | ||
| <dd> add name=value</dd> |
There was a problem hiding this comment.
Opinions solicited: There is an argument that this and has_key() belong over in the "Functions" section.
| <dd> add name=value</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = obj["name"];</a></code></dt> | ||
| <dd> get value from object by string</dd> | ||
| <dd> get value from object by name</dd> |
There was a problem hiding this comment.
Discuss: Hmm. Using "string" there was deliberate, to emphasize that it was an arbitrary string expression, as opposed to an limited-to-identifier-and-constant name for the next.
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(…,object,…);</a></code></dt> | ||
| <dd> copy</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(…,name=value,…);</a></code></dt> | ||
| <dd> assign/override</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(…,[…,["name"],…],…);</a></code></dt> | ||
| <dd> remove name</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(…,[…,["name",value],…],…);</a></code></dt> | ||
| <dd> add name=value</dd> |
There was a problem hiding this comment.
Futures: I have mixed feelings about the "name" style, with the quotes. There are examples both ways through the cheat sheet, showing a sample value or showing the name of the argument. One would hope that people would understand that "name" is a sample and that you could use an arbitrary string expression there, but I've seen people who think that in cube([10,10,10]) the brackets are part of the syntax of cube(), or that in rands(1,10,1)[0] the [0] is part of the syntax.
It's certainly fine for now.
We should also work on consistency in how argument names are presented; we have cases where they are plain text, are part of the link or not, are gray, are italics. We have most functions not mentioning their arguments, but a couple do. But Not This Project.
| <dd> get value from object by name</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = obj.name;</a></code></dt> | ||
| <dd> get value from object by identifier</dd> | ||
| <dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Has_key">has_key(object,"name");</a></code></dt> |
There was a problem hiding this comment.
Change: anchors for other functions are in lower case.
@jordanbrown0 could you take a look? I am also ok if you want to take this over since you already edited this cheat sheet.