Skip to content

Added object() in cheat sheet for snapshot #159

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions cheatsheet/snapshot.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,20 @@ <h2>Lists</h2>
<article>
<h2>Objects</h2>
<dl>
<dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(&hellip;,object,&hellip;);</a></code></dt>
<dd>&nbsp;&nbsp;copy</dd>
<dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = object(&hellip;,name=value,&hellip;);</a></code></dt>
<dd>&nbsp;&nbsp;assign/override</dd>
<dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(&hellip;,[&hellip;,["name"],&hellip;],&hellip;);</a></code></dt>
<dd>&nbsp;&nbsp;remove name</dd>
<dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects_edits">var = object(&hellip;,[&hellip;,["name",value],&hellip;],&hellip;);</a></code></dt>
<dd>&nbsp;&nbsp;add name=value</dd>
Comment on lines +170 to +177
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation: I would order these as

  • name=value
  • object
  • [[name,value]]
  • [[name]]
    because I think name=value is the most likely variant.

Comment on lines +170 to +177
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinions solicited: There is an argument that this and has_key() belong over in the "Functions" section.

Comment on lines +170 to +177
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

<dt><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Objects">var = obj["name"];</a></code></dt>
<dd>&nbsp;&nbsp;get value from object by string</dd>
<dd>&nbsp;&nbsp;get value from object by name</dd>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = obj.name;</a></code></dt>
<dd>&nbsp;&nbsp;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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change: anchors for other functions are in lower case.

<dd>&nbsp;&nbsp;</dd>
</dl>
</article>
<article>
Expand Down Expand Up @@ -212,6 +222,8 @@ <h2>Type test functions</h2>
<code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Type_Test_Functions#is_function">is_function</a></code>
<code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Type_Test_Functions#is_object">is_object</a></code>
</article>
</section>
<section>
Comment on lines +225 to +226
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

<article>
<h2>Other</h2>
<code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#echo">echo</a>(&hellip;)</code>
Expand All @@ -220,9 +232,6 @@ <h2>Other</h2>
<code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#assert">assert</a>(condition, message)</code>
<s><code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Conditional_and_Iterator_Functions#Assign_Statement">assign</a> (&hellip;) { &hellip; }</code></s>
</article>
</section>

<section>
<article>
<h2>Functions</h2>
<code><a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Mathematical_Functions#concat">concat</a></code>
Expand Down