TheCoffeMaker_ has quit [Ping timeout: 260 seconds]
TylerTork has joined #openscad
<TylerTork>
Has anyone been using the "Print a Thing" service from within OpenSCAD (F8 key)? It's giving me an error message "ERROR: Error transferring https://print.openscad.org/api/v1/part-upload/?source=openscad - server replied: Internal Server Error"
<JordanBrown>
I had forgotten that I had backed out the support for hex constants, because they are in theory a backward compatibility problem: OpenSCAD allows variables that start with digits.
<InPhase>
Maybe check hex constants in the symbol table, and otherwise, a constant?
<InPhase>
And maybe also we should deprecate variables that look like hex constants...
TylerTork has quit [Ping timeout: 250 seconds]
<JordanBrown>
I'd be in favor of calling that simply a bug, but I happen to know that our favorite person-who-relies-on-bugs relies on it.
<InPhase>
lol
<JordanBrown>
Correction: I'd be in favor of calling it a bug that those start-with-digit names are allowed.
<JordanBrown>
I know that he uses start-with-digit names.
<JordanBrown>
I don't know that he uses names that start with 0x.
<InPhase>
I'd also favor deprecating them all, but we could special case 0x as deprecated for less disruption.
<InPhase>
Maybe 0b too.
<InPhase>
I guess we have no use for 0o?
<InPhase>
If you're doing bitwise operators though, 0b is reasonable.
<kintel>
I agree that killing support for symbols starting with a number would be a good thing.
<kintel>
I wonder how hard it would be to establish some sort of compatibility mode or planned future deprecation to allow stragglers to update their code within some set time frame
<kintel>
But could be that we'd need some messy heuristics to detect hex/bin literals in the intermi
<kintel>
2/2 Test #37: echotest_bitwise-operators .......***Failed
<kintel>
JordanBrown do all tests pass for you?
J24k73 has joined #openscad
J24k82 has quit [Ping timeout: 250 seconds]
<JordanBrown>
Haven't checked in a long time.
<JordanBrown>
I think they all passed when I did the work months ago.
<JordanBrown>
I think a compatibility mode would look like having the lexer rule that recognizes hex constants (or binary constants) alternatively do the same thing that the symbol rule does.
<JordanBrown>
Those two tests pass for me on Windows.
pca006132 has quit [Remote host closed the connection]
<kintel>
Huh, on my machine, (-1 | 0) evaluates to zero?
<JordanBrown>
evaluates to 4G for me.
<JordanBrown>
building on my Linux VM, but that will take a while.
<JordanBrown>
I would have to go look at the standards for the rules for casts from double to unsigned int.
<JordanBrown>
But the arithmetic is not complicated. Look for operator| in src/core/Value.cc.
<JordanBrown>
You might try (-1 & 1) and other variations involving negative numbers.
<kintel>
Oh
<kintel>
naked cast from double to int
<kintel>
That's probably UB in C+
<kintel>
*C++
<JordanBrown>
Could easily be. Have I mentioned that I'm a C++ newbie?
<kintel>
uint32_t a = (uint32_t)-1.0;
<JordanBrown>
My C career could easily have a grandchild, but C++ not so much.
<kintel>
-> this gives me a ~random result for each run
<kintel>
I guess undefined behavior includes different behavior per execution if the compiler really wants to : /
<kintel>
I guess go back and see how JavaScript does it ;)
<JordanBrown>
what #include do I need to make that compile?
<kintel>
#include <iostream>
<kintel>
This is on clang on Apple Silicon btw., which isn't tested on our CI
<JordanBrown>
I'm reliably getting 0.
<JordanBrown>
which is pretty wrong too.
<JordanBrown>
That is, on the little test program.
<kintel>
I get 0 on a raspberry pi too (the only Linux box I had booted)
<JordanBrown>
but (-1|0) gets 4G on my Linux system.
<JordanBrown>
That is, in OpenSCAD.
<kintel>
Undefined can mean anything..
<kintel>
The spec says "If the value cannot fit into the destination type, the behavior is undefined"
<kintel>
I'm sure there is a neat trick, like double -> int -> uint, but check some JavaScript implementation as they likely do it in an optimal fashion
<kintel>
I'll make another try at getting an M1 machine provisioned on GiyHub CI
<JordanBrown>
If I add a cast to (int) in the middle, the little test program yields 4G.
<JordanBrown>
(That's GCC on MINGW/MSYS2 on Windows.)
<JordanBrown>
But hmm. Cast to int in theory will fail for values 2G to 4G.
<JordanBrown>
Probably cast to (a) apply limits (b) cast to int64_t (c) cast to uint32_t.
kintel has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<JordanBrown>
I changed to what might be a more robust conversion from double to int. See toUint32 and toInt32 in Value.cc.