teepee changed the topic of #openscad to: OpenSCAD - The Programmers Solid 3D CAD Modeller | This channel is logged! | https://openscad.org/advent-calendar-2021/ | Website: http://www.openscad.org/ | FAQ: https://goo.gl/pcT7y3 | Request features / report bugs: https://goo.gl/lj0JRI | Tutorial: https://bit.ly/37P6z0B | Books: https://bit.ly/3xlLcQq | FOSDEM 2020: https://bit.ly/35xZGy6 | Logs: https://bit.ly/32MfbH5
zauberfisch has quit [Ping timeout: 240 seconds]
myosotis has quit [Quit: myosotis]
zauberfisch has joined #openscad
ferdna has joined #openscad
ur5us_ has joined #openscad
J225 has joined #openscad
J22 has quit [Ping timeout: 256 seconds]
LordOfBikes has quit [Ping timeout: 272 seconds]
LordOfBikes has joined #openscad
Guest18 has joined #openscad
Guest18 has quit [Client Quit]
ur5us_ has quit [Ping timeout: 240 seconds]
J22597 has joined #openscad
J225 has quit [Ping timeout: 256 seconds]
ferdna has quit [Quit: Leaving]
J22597 has quit [Ping timeout: 256 seconds]
kiba has joined #openscad
ur5us_ has joined #openscad
ur5us_ has quit [Remote host closed the connection]
peeps[zen] has joined #openscad
ur5us_ has joined #openscad
Scopeuk has quit [Quit: Ping timeout (120 seconds)]
Scopeuk has joined #openscad
peepsalot has quit [Ping timeout: 240 seconds]
foul_owl has quit [Ping timeout: 250 seconds]
ur5us_ has quit [Ping timeout: 240 seconds]
arebil has joined #openscad
foul_owl has joined #openscad
zauberfisch has quit [Ping timeout: 240 seconds]
zauberfisch has joined #openscad
zauberfisch has quit [Ping timeout: 272 seconds]
teepee has quit [Remote host closed the connection]
teepee has joined #openscad
J22 has joined #openscad
ur5us_ has joined #openscad
trashbird has quit [Quit: Ping timeout (120 seconds)]
trashbird has joined #openscad
arebil has quit [Quit: My keyboard has gone to sleep. ZZZzzz…]
arebil has joined #openscad
ur5us_ has quit [Ping timeout: 240 seconds]
J229 has joined #openscad
J22 has quit [Ping timeout: 256 seconds]
arebil has quit [Quit: My keyboard has gone to sleep. ZZZzzz…]
arebil has joined #openscad
foul_owl has quit [Ping timeout: 240 seconds]
kiba has quit [Quit: Client closed]
foul_owl has joined #openscad
arebil has quit [Quit: My keyboard has gone to sleep. ZZZzzz…]
J229 has quit [Quit: Client closed]
J229 has joined #openscad
Guest83 has joined #openscad
Guest83 has quit [Client Quit]
myosotis has joined #openscad
willmore has quit [Remote host closed the connection]
J229 has quit [Quit: Client closed]
J229 has joined #openscad
LeviHarris-Brown has joined #openscad
J229 has quit [Quit: Client closed]
J229 has joined #openscad
little_blossom has quit [Quit: little_blossom]
little_blossom has joined #openscad
arebil has joined #openscad
Guest82 has joined #openscad
Guest82 has quit [Client Quit]
GNUmoon has quit [Remote host closed the connection]
arebil has quit [Quit: My keyboard has gone to sleep. ZZZzzz…]
GNUmoon has joined #openscad
jonasbits has joined #openscad
arebil has joined #openscad
Guest2064 has joined #openscad
Guest2064 has quit [Client Quit]
arebil has quit [Quit: My keyboard has gone to sleep. ZZZzzz…]
Virindi has joined #openscad
<Virindi> oh my gosh, the operator precedence in openscad just sent me on a wild goose chase from hell
<Virindi> foo = true;
<Virindi> bar = 3 + foo ? 1 : 2;
<Virindi> echo(str("BAR: ",bar));
<Virindi> what do you expect is the value of bar? :P
<Virindi> Answer: 2. This seems totally wrong to me, it seems that "+" has too high a prec
<myosotis> yeah, I was gonna guess 2, just based on the fact that it was making you crazy lol
<Virindi> sorry, I spoiled it.
<myosotis> I think every language has it's "gotchas" though
<Virindi> usually I add paranoia parentheses and this time I forgot to
<Virindi> and by the way, in c++,
<Virindi> int bar = 3 + foo ? 1 : 2;
<Virindi> bool foo = true;
<Virindi> ...results in 1. So maybe there is just no good answer
<myosotis> yeah the docs could be clearer. The only documentation I can find for order of operations is a SO answer pointing to source code.
<myosotis> the more languages I use, the more explicit I become.
<Virindi> but the fact that openscad has a different prec order than c/cpp seems bothersome
<Virindi> or I guess, just different comparison
<Virindi> 3+true is true
<Virindi> and in openscad I guess 3+true is false
<myosotis> it seems to have close to the same precedence as php, which I have to use professionally
<Virindi> I never, ever use the ? operator in real programming languages. Probably another part of the problem. I think it makes code harder to read than an 'if' statement
<myosotis> parenthesis for programmers are like clamps for woodworkers. you can never have too many :)
<Virindi> well of course, you use PHP, if you miss a paren it will probably assume you mean "send a web request to the last string in the stack" :P
<myosotis> I never use ternary because I can't ever remember which languages support it. and as you said, an if/then is quicker than a web search and infinitely readable in any language.
<Virindi> I have nested ? piles in openscad that make me very sad and are impossible to read. Really wish I could use 'if'
<Virindi> but that's a different issue
<myosotis> I think the first couple paragraphs of https://forum.openscad.org/The-OpenSCAD-Language-td26237.html are salient here
<myosotis> I think at some point it's better to describe or build your project using other tools/languages, and restrict openscad to representing their 3d state
<Virindi> I know it is preference. The problem is that openscad is just BARELY not like a sequential, imperative language, so normally I can pretend it is. Then suddenly I hit a wall because it is not.
<Virindi> I also am not personally a fan of the 'functional' pattern. Preference.
<myosotis> I used to care. Now I'm more a fan of the "whatever pattern the people around me already understand" approach
<Virindi> Also, things from the sequential world do break through into openscad. For example, the order of declarations matters, and you constantly have to worry about it.
<Virindi> so it is not "pure" functional
<Virindi> there is not a way to do a forward declaration, is there? Of a variable?
<Virindi> I constantly have to rearrange my list of calculations because of dependencies
<Virindi> don't get me wrong, I love openscad, it is 99% of what I want, it's just that that last 1% gets annoying sometimes
<clemens3> i just did very little openscad so far, but basically generate the code with ruby and in ruby i use all the variables i like..
<clemens3> and don't much care about the openscad idioms anymore
<clemens3> but didn't dive deep into it, so don't know how limited that approach is
<Virindi> I always considered generating openscad with another language but it sure seems like a hack
<myosotis> quite the opposite
<clemens3> well, openscad obviously is a hack
<myosotis> use openscad for what it's good at
<myosotis> and use your favorite language for what it's good at
<clemens3> and the other way around is just like a 2 pass compiler assembler
<clemens3> exactly
<clemens3> obviously nobody uses openscad for its beautifyl programming language..
<clemens3> but for scripting 3d it is great
<myosotis> the entire world is running on duct tape. purity of implementation is a myth
<clemens3> well, if openscript would be pure and simple and beautifyl, I would use it for everything
<clemens3> you can use haskel or guile if that is your cup of tea
<clemens3> even bash is maybe more useful:)
<clemens3> or visual basic
<myosotis> we have a client that uses an application that runs VBScript as part of production operations
<clemens3> Virindi: just give it 5 minutes, it is so simple actually
<Virindi> nah
<myosotis> I can't afford to care much about what language I'm using
<Virindi> I'd have to write a conversion tool for my existing 10000000gb of scad files
<clemens3> ah, professional, no problem
<myosotis> no conversion necessary. Leave them all as they are. Just maybe try to use another language to manage the higher level details of your next project and see how it goes.
<clemens3> actually that is true, your openscad generator just reads the data and generates the openscad source
<Virindi> the main reason I always wanted a higher level language was actually to do constraint sketches, which would be cool
<clemens3> don't know about your details, but i have logic.rb < mydata.csv > cad.scad or something like that..
<Virindi> oh, I was thinking more like create methods in the real language for union, difference, cube, etc, then write openscad-like code directly in it
<Virindi> rather than reading some file
<Virindi> could do better error checking that way too, like if you try to mix a 2d object with 3d objects without extruding it could tell you
<Scopeuk> if you want to play with full programming languages there are csg libraries for python or c++ which will let you define solid geometry that way, have never felt the need myself but most of my models are quite brutalist to be generous
ur5us_ has joined #openscad
ur5us has joined #openscad
ur5us_ has quit [Read error: Connection reset by peer]
GNUmoon has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #openscad
ur5us has quit [Ping timeout: 240 seconds]
<gbruno> [github] dannypike opened issue #4122 (Right-click menu turns everything black) https://github.com/openscad/openscad/issues/4122
<peeps[zen]> Virindi: i dont think precedence is different from c/c++ issue, it's just that mixed types in opreations are undefined behavior in OpenSCAD:
<peeps[zen]> WARNING: undefined operation (number + bool) in file , line 2
<Virindi> ya I corrected myself right after I said it
<gbruno> [github] dannypike edited issue #4122 (Right-click menu turns everything black) https://github.com/openscad/openscad/issues/4122
<Virindi> the real issue is just that chains of ? are not readable code, which is not unique to openscad other than the fact that openscad forces you to use ?
<gbruno> [github] t-paul closed issue #4122 (Right-click menu turns everything black) https://github.com/openscad/openscad/issues/4122
<peeps[zen]> if / else are statements, ? : is an expression, apples and oranges
<teepee> well, the parser is modeled exactly after the C++ operator precedence :)
<teepee> a cascade of if/else is not much better, some dedicated switch might be a more usable option
<Virindi> I find:
<Virindi> foo=1;
<Virindi> else
<Virindi> if (condition)
<Virindi> foo=2;
<Virindi> to be much more readable than:
<Virindi> foo=condition?1:2;
<Virindi> especially when multiple conditions are stacked, regardless of where I place line endings or indents
<Virindi> and yes, lack of switch is painful
<teepee> actually not so much switch, but more match or whatever that's called nowadays
<Virindi> just yesterday I had a situation where I wanted to assign a variable a value based on one of several possibilities. It had to look like this:
<Virindi> foo = (possibility1?a : (possibility2? b : (possibility3? c :.......
<Virindi> is that really how you want your code to look :)
<teepee> well, you *could* write it in a slightly better readable way :)
<Virindi> it still requires a lisplike massive nest
<teepee> but yes, multiple ternary are not great but it works without braces
<Virindi> in c, even if switch were not allowed, you could do
<Virindi> else if (possibility2) foo=b;
<Virindi> if (possibility1) foo=a;
<Virindi> else if (possibility3) foo=c;
<Virindi> etc and that is very easy to read
<Virindi> I am terrified to use ? without parens now :P
<teepee> no you can't as that breaks scoping rules
<Virindi> what do you mean can't
<teepee> well, I suppose it would be possible to define it like that for expressions
<teepee> it's even allowed in list comprehensions
<teepee> but there would be no ;
<myosotis> ?: is a nice shortcut, but sometimes you really want to take the scenic route
<teepee> hmm, Michael hat a nice example for reasonable formatting of nested ternaries, but I can't find that right now :(
<myosotis> there's a reason you can't find an example of reasonable formatting of nested ternaries lol. I think that's the point. Yes it's usable, but man it gets messy quickly and easily
<myosotis> time spent meta-coding is a waste imho
<teepee> read again, and ignore the s/hat/had/ typo
<Virindi> yeah any language feature which makes it easy to write unreadable code and hard to write readable code, is bad imo
<peeps[zen]> i tend to do:
<peeps[zen]> (condition ?
<peeps[zen]> false_result
<peeps[zen]> true_result :
<peeps[zen]> )
<peeps[zen]> and each new condition gets another level of indentation
<Virindi> not bad but of course the lack of parens is scary
<Virindi> perhaps just always put the condition in parens.
<Virindi> then that might look nice
<teepee> ternary has weakest binding for a reason
<myosotis> a programmer would have to be certain of precendence to be bold enough to produce that
<peeps[zen]> even better imo: function map(x) = [undef,"a","b","c","d"][x];
<teepee> yeah, for number input :P
<Virindi> not correct?
<Virindi> if x is not 1,2,3 then it should be d
<teepee> it works for exactly the cases I gave as example and is better for that case
<teepee> but the ternary will give "d" for everything >= 4
<teepee> so it depends
<Virindi> sure
<teepee> the ternary version allow even for x == 1 ... x == "a" ... x == true
<Virindi> I consider an echo statement to be a random debug test rather than information about how the thing should behave ;)
GNUmoon has joined #openscad
myosotis has quit [Quit: myosotis]
<J229> unreadable code is always the code you are not familiar with its syntax .. if you get  used to  it gets much easier and you might even understand what happens in https://github.com/thehans/funcutils/blob/master/string.scad
<OlivierChafik[m]> Hi everyone
<OlivierChafik[m]> teepee: trying to stabilize post-corefinement remeshing (nearly there!), but thought I'd send a huge refactoring first to make my life a merge nightmare :-)
josephl has quit [Read error: Connection reset by peer]
josephl has joined #openscad
ali1234 has joined #openscad
<teepee> OlivierChafik[m]: haha, perfect timing, I'm off to bed, crazy weather outside and talk of nightmares :P
<teepee> I'll have a look tomorrow :)
<OlivierChafik[m]> Ooops bad choice of words haha, sleep light like an optimized vectorizable loop
<OlivierChafik[m]> *tight
<OlivierChafik[m]> (ugh need to sleep too it seems)