<kintel>
teepee: I noticed that CircleCI fails to build macOS snapshots. Fixing it is prob. not hard, but do you know how to get CircleCI to complain more loudly when this happens (especially for snapshot builds), so someone can take notices?
<teepee>
I tried to enable notifications going to #openscad-ci but did not finish that yet
<teepee>
it currently can't run git due to some library mismatch, not sure how to fix that
<kintel>
At least the github badge is red
<teepee>
yes it updates after the scheduled run per commit
<kintel>
oh, I see, I was away for a few days and didn't check the IRC log. I'll look into it
<teepee>
I could not make it work last time, as their irc-orb needed some tools installed we did no have, at least appimage and windows should now have it
<Paul94>
function limit(x, min, max) = max(min(x, max), min);
<Paul94>
echo(limit(-1,0,100));
<Paul94>
echo(limit(200,0,100));`
<Paul94>
I cannot understand how OpenSCAD resolves function calls: I can redefine a standard function, and minWrapped will pick it up. But if there's a variable with same name the interpreter will get "smart" using either var or function.
<Paul94>
But when choosing a function it chooses a standard function, not a redefined one.
<teepee>
there's only one suggestion, don't use the same name
<teepee>
legacy behavior is 3 separate namespaces which did not cause problems as there was no overlap
<Paul94>
yeah, that's what I've figured, but limit is taken from NopSCADlib. so seems like code like that will be maintained for quite a while.
<teepee>
but where's the min = function() overwrite coming from?
<InPhase>
Yeah, you definitely don't want to redefine cores like min. That's hazardous. :)
<Paul94>
min was my addition. Long story is I have my own openscad interpreter, and noticed that limit is broken.
<Paul94>
Started experimenting with all the ways a function can be redefined and cannot understand all the rules.
<InPhase>
Paul94: Basically, we had legacy functions, and then we introduced function literals which are assigned to variables. This disrupted the principle of three separate namespaces for functions, variables, and modules, which were previously determined purely from syntactic context in the original design.
<InPhase>
Paul94: Really we should NOT have three separate namespaces, but this is sort of baked in now for backward compatibility. It might be worth at some point formally deprecating the reuse of variable names between these namespaces, and eventually migrating away from this. But that would have to have a very long lead time, and it would break at least a small amount of old code where this namespace
<InPhase>
division had been relied upon (perhaps unwisely).
<InPhase>
Paul94: But, for now, we have a lookup order through the contexts.
<Paul94>
Yes, that's how stories usually go with compilers :) Three namespaces sounded logical, I too started with that. What is current resolution order? Parser sees a function call with an identifier as a function. It checks functions namespace, then standard functions, then variables?
J23k33 has quit [Quit: Client closed]
J23k33 has joined #openscad
<InPhase>
Paul94: Hopefully this illustrates the lookup a bit? https://bpa.st/G2AHS
<Paul94>
Thanks, now I understand even less :)
<Paul94>
guess I'll have to read the code.
<InPhase>
Well knowing better what you don't know is progress!
<Paul94>
That snippet prints `ECHO: "x = function()"
<Paul94>
ECHO: "x = function()"
<Paul94>
ECHO: "y = Foo function()"`
<Paul94>
but I was expecting second echo to be "Foo function"
<Paul94>
Module cannot define a function, can it?
Paul94 has quit [Quit: Client closed]
kintel has joined #openscad
Paul94 has joined #openscad
Paul94 has quit [Client Quit]
<kintel>
FYI: The macOS build failure was caused by a stray libintl.8.dylib file in our library cache. We've since disabled building dynamic libintl, so this was leftover from an old build. Fix is to bump MACOS_CACHE_VERSION on CircleCI to trigger a full dependency rebuild
Paul94 has joined #openscad
<kintel>
The real issue is that we pollute the build environment with libraries (we set DYLD_LIBRARY_PATH), since we're building for a different target than the build image itself. Not sure if there is a good way around that. Perhaps we could set DYLD_LIBRARY_PATH as late as possible, and not run tools like 'git' while it's set?
<kintel>
..or perhaps one day, Docker for macOS will happen
Paul94 has quit [Client Quit]
Paul94 has joined #openscad
Paul94 has quit [Client Quit]
<kintel>
Also, the library cache is a bit brittle since gettext has a build system which keeps changing. The libintl stuff has been a major pain to get built :(
<Scopeuk>
why are build systems so painful. no matter what you are building, or where or why, they always want to start a fight
<kintel>
It's annoying.
<kintel>
I postulate that one day, the only native piece of software left will be web browsers, everything else will run in some VM/runtime on top of that.
<kintel>
Perhaps modulo distro packages
<teepee>
luckily there's only one javascript build system
<peepsalot>
lol
<kintel>
Heh, and by the time we get there, who wants to bet that Web APIs have splintered into 3 or 4 competing stacks?
anotherlucas[m] has quit [Remote host closed the connection]
<Lagopus`>
1st time I've wanted to change variables in a loop, is there no var = var + 1 ;or var++ ; or var = var/2 ; ? If not I will need to rework variable handling. It seems like a variable can be set once and is const only unless specified in the loop conditional. Also scope: is there no scope in openscad?
<InPhase>
Lagopus`: It is a declarative language rather than an imperative language, which requires a slight shift in thinking.
<Lagopus`>
then consider me brain-shifting at the moment
<InPhase>
Lagopus`: There is one location where var = var + 1 is allowed, and that's in the C-style for loop list comprehension.
<InPhase>
Lagopus`: In general if you want to do something like var = var + 1, you do so with recursion, either function recursion or module recursion.
<Lagopus`>
yes, I'll need to run all the math based on the conditional variable instead of changing other variables in the loop body
<InPhase>
Lagopus`: And next in this conversation, you either say, "Ah, okay." or "Oh no, I have no idea how recursion works", or something in between.
<Lagopus`>
is that a JoJo reference?
<InPhase>
Not intentionally.
<InPhase>
Lagopus`: Function recursion can be setup to do exactly the same things that you would do with iterative looping. The best way to do it depends a little on the particular problem, so if you're having issues show an example of what you're trying to do and then maybe one of us can advise.
teepee has quit [Ping timeout: 240 seconds]
teepee has joined #openscad
<Lagopus`>
I'll ix.io you an example of what I'm changing
<InPhase>
Lagopus`: We've also implemented efficient list concatenation for recursive functions, modeled after how Lisp handles this, so one approach is to build up a list of the values you need, and then loop over them to make your geometry.
<InPhase>
Lagopus`: Other times it's better to do recursion directly on the modules, particularly if you're moving along some path or something.
<InPhase>
Lagopus`: My favorite example (because it makes me smile) of module recursion is the happy_grass.scad example in the top middle of last year's calendar: https://openscad.org/advent-calendar-2022/
<Lagopus`>
http://ix.io/4wcN ok so here's my changes, although I still need to figure out what is incorrect about my use of floor()
<InPhase>
And is the goal to make new_ match the output of old_ ?
<Lagopus`>
old_ won't work based on what you said. new_ does actually work like you said
<InPhase>
Ah.
<InPhase>
Oh, you're doing a bit iteration?
<Lagopus`>
my core2 duo e7500 can't seem to handle that link you sent
<Lagopus`>
yes
<Lagopus`>
honestly I'd like a bitwise shift and bitwise & but /2 and %2 are the best I will get
<InPhase>
So if you ever really need to work with bits, the expected mode of thinking is to make lists of them.
<InPhase>
We did briefly discuss additional bitwise operator support, but as we have doubles for the values it didn't seem quite right to do. The logic of it is still doable though.
<InPhase>
But definitely masking is not a thing one should do for efficiency in OpenSCAD. If you can work with lists from the beginning, this is the more natural way.
<InPhase>
You'll find that there is almost never a performance issue due to value computations in OpenSCAD, but it is almost always only an issue of performance for calculating the geometries.
<InPhase>
The value computation is typically more than fast enough to stay way ahead of the geometry calculation overhead.
<Lagopus`>
Thanks for the paste. My function was pretty much the make_ring_of function in examples but when running multiple rings close together, my goal was to take one or two of the iterations out to avoid overlap
<Lagopus`>
you can also blame my train of thought of being based in c & asm instead of these higher languages
<InPhase>
Yeah. :) It is a shift.
<InPhase>
It's Turing Complete (to within recursion limits), so there is always a way. But some things will be more of a struggle than needed if you try to press to do things in the unnatural way.
<InPhase>
I think it can be worthy exercises though to try to do things in the unnatural way once in a while, to explore the language and understand its extrema better.
peeps[work] has quit [Remote host closed the connection]
peeps[work] has joined #openscad
peeps[work] has quit [Remote host closed the connection]
<InPhase>
For a dynamic make_ring_of I would simply calculate the number to put in the ring right before the loop, and use that rather than the passed in maximum count.
peeps[work] has joined #openscad
<InPhase>
Like, calculate the circumference, divide, ..., do a max.
<InPhase>
I mean, min
<InPhase>
Then it will smoothly reduce as it shrinks.
<Lagopus`>
that actually looks really similar to dvorak
<Lagopus`>
I don't normally type outside of ascii, but maybe I'll try it out one day
J23k33 has quit [Quit: Client closed]
J23k33 has joined #openscad
kintel has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snaked has quit [Quit: Leaving]
tgunr has joined #openscad
foul_owl has joined #openscad
<tgunr>
I've been at this all afternoon trying to create a transition between 2 hollow cylinders of different diameters. I have modules to build the cylinders specifying the diameter and thickness and whether the diameter is considered to be the inside or outside. But trying to figure the transition between the cylinders in a hollow code is eluding me.