teepee changed the topic of #openscad to: OpenSCAD - The Programmers Solid 3D CAD Modeller | This channel is logged! | 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
<JordanBrown1> Only on a 4-bit computer.
<bitbasher> The result is equal to the two's complement of the value minus one. If two's complement arithmetic is used, then NOT x = -x − 1.
<JordanBrown1> ~7 is 1111111111...111000.
<JordanBrown1> with an infinite number of 1s.
<JordanBrown1> But here, use bitwise and to pull the value apart into bits:
<JordanBrown1> x = ~4;
<JordanBrown1> echo([ for (i=[31:-1:0]) (x & (1 << i)) ? 1 : 0 ]);
<JordanBrown1> ECHO: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1]
<bitbasher> does not matter how many bits you use .. 4 to 64 .. if you flip the bits you have bit wise negation
<JordanBrown1> Yes.
<bitbasher> we seem to be agreeing very Very hard here Jordan
<JordanBrown1> And if you flip the sign bit... which happens when you do a *signed* bitwise NOT, you end up with a negative number.
<JordanBrown1> (Or, contrariwise, if you started with a negative number you end up with a positive number.
<JordanBrown1> )
<bitbasher> and that is why the scad bitwise NOT is not correct
<JordanBrown1> tRY IT IN c.
<bitbasher> at least compared to C and other langs
<JordanBrown1> Try it in C.
<JordanBrown1> Or Python:
<JordanBrown1> $ python
<JordanBrown1> Python 3.12.10 (main, Apr 18 2025, 06:12:01) [GCC 14.2.0 64 bit (AMD64)] on win32
<JordanBrown1> >>> print(~4)
<JordanBrown1> Type "help", "copyright", "credits" or "license" for more information.
<JordanBrown1> -5
<bitbasher> i am not set up for C on this puter
<JordanBrown1> >>> ^Z
<bitbasher> yep .. also not correct bitwise .. still two comp
<bitbasher> anyway .. all i was concerned with was the accuracy of my description of the bitwise operators and i am now content
<JordanBrown1> Or in JavaScript
<JordanBrown1> $ python
<JordanBrown1> Python 3.12.10 (main, Apr 18 2025, 06:12:01) [GCC 14.2.0 64 bit (AMD64)] on win32
<JordanBrown1> Type "help", "copyright", "credits" or "license" for more information.
<JordanBrown1> -5
<JordanBrown1> >>> print(~4)
<JordanBrown1> >>> ^Z
<JordanBrown1> Oops...
<JordanBrown1> Welcome to Node.js v14.18.0.
<JordanBrown1> Type ".help" for more information.
<JordanBrown1> > console.log(~4)
<JordanBrown1> -5
<JordanBrown1> undefined
<bitbasher> still not bitwise
<JordanBrown1> You keep saying that, and you keep being wrong :-)
<bitbasher> the scad bitwise & and | work correctly so masking and so on works
<JordanBrown1> printf("%d\n", ~4)
<JordanBrown1> will print -5.
<bitbasher> LOL
<JordanBrown1> You are just used to thinking in unsigned.
<JordanBrown1> OpenSCAD numbers are always signed. There is no unsigned.
<bitbasher> yes indeed .. for the bitwise ops that is the One True Platform
<JordanBrown1> If you ignore signed :-)
<JordanBrown1> But OpenSCAD bitwise operators behave exactly the same as C bitwise operators *on signed values*.
<bitbasher> the ~ could be "fixed" to undo the flipping of the sign and give correct UNSIGNED bitwise result .. but i dont insist on it .. such a rare thing to need
<JordanBrown1> ... because that is how they are implemented :-)
<bitbasher> yep .. i get that .. never do bitwise on signed ints .. that was always my rule
<JordanBrown1> For a while I had them be based on unsigned, and I think it was specifically ~0 that was the reason for making them signed.
<bitbasher> but then, i rarely did math in C .. my early days were in machine control and UI stuff
<JordanBrown1> For one thing, it nicely hides how wide the arithmetic is.
<JordanBrown1> In signed arithmetic, ~0 is -1 no matter how wide your arithmetic is.
<bitbasher> and isn't that a pain trying to flip bits in a port register !!!
<JordanBrown1> And ~1 is -2 as long as you have at least two bits.
<JordanBrown1> If you have only one bit, you only get -1 and 0.
<bitbasher> Jordan .. can u please cast an eye .. or two at https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Objects for me?
<bitbasher> i think i have captured all the notes you made in the forum and github pages
<JordanBrown1> In the initial section "Built-in Object Creators"... do the sections on numbers, strings, and vectors similarly have a list of the built-in mechanisms that create them?
<bitbasher> there is still a bit of work to be done, more examples and images
<JordanBrown1> You list textmetrics() and fontmetrics() as just the function, but you say 'data = import()".
<bitbasher> and i would ask you permission to publish that nice example animation as an example
<bitbasher> yeah .. that is one of the parts that needs correction and fleshing out
<JordanBrown1> I'm happy to have it used, but it's way too big to be an example for a reference manual.
<JordanBrown1> One place it will probably end up published is in the advent calendar.
<bitbasher> it will be added to the examples page .. not lang ref
<JordanBrown1> And of course object() is an object creator.
<JordanBrown1> The "Objects are currently experimental" sentence is sort of correct. All of the current object-creating functions are experimental and must be enabled.
<bitbasher> i want to collect all the example scripts in the lang ref and make them visible in the app .. the file menu > Examples and the splash panel
<JordanBrown1> "are used interchangeably" is a yellow flag. Pick one nomenclature or the other, and stick with it.
<JordanBrown1> / ECHO: Fred = { name = "Fred"; spouse = "wilma"; friend = ["barney"]; }
<JordanBrown1> s/friend/friends/
<JordanBrown1> When the value is the result of an expression or function call but is undef the member is still added:
<JordanBrown1> That's just normal OpenSCAD semantics.
<JordanBrown1> undef is a value, and can be used in any context where a value can be used.
<bitbasher> i would normally .. but it is like array = vector = list .. the terminology comes from diff backgrounds and there is a good bit of tradition to follow in nomenclature .. well, IMHO
<JordanBrown1> But in any new material you should be consistent.
<JordanBrown1> Note: a later setting for a particular member will replace any earlier definition. This attribute of the language can give unexpected results with member definitions.
<JordanBrown1> This is not relevant to objects, and has no special interaction with objects.
<JordanBrown1> Oh, wait, I misread.
<JordanBrown1> The first half of that sentence is correct.
<JordanBrown1> The second half, not so much. It's a deliberate feature.
<JordanBrown1> Or, rather, the first sentence is correct, and the second sentence not so much.
<bitbasher> you will see some of the Unexpected Effects in later examples
<JordanBrown1> It is very deliberate that o=object(a=1,b=2); o2 = object(o, a=3); yields { a=3, b=2 }.
<JordanBrown1> Where the <name> is any expression resulting in a string and the value is any valid expression, specifically including object.
<bitbasher> i do not say it is a bug .. it is a feature of the language .. but combining objects gives some .. odd results
<bitbasher> and i may have found some bugs as well .. not sure yet
<JordanBrown1> I expect that it works exactly as designed. I'll keep looking.
<JordanBrown1> Where the <name> is any expression resulting in a string and the value is any valid expression, specifically including object.
<JordanBrown1> that last phrase is unnecessary and I wouldn't include it.
<JordanBrown1> "any expression" includes any expression, period. If you start saying "including FOO", then people may start to think that anyplace that doesn't say "including FOO" doesn't include FOO.
<bitbasher> i will make the point about assigning undef clearer .. when a member's value should be calculated by a function but it fails and returns undef .. that is the situation i was trying to cover .. the object is created with no warnings so it is programmer beware
<JordanBrown1> ... and there's nothing special about objects there.
<JordanBrown1> Indeed, there are a few cases where expressions will yield undef, and that undef may cause problems downstream.
<JordanBrown1> But it is more correct to say that a list argument is for performing bulk editing
<JordanBrown1> No. Or, rather, all of the variations perform editing.
<JordanBrown1> Vector-style is the only way to do a deletion.
<JordanBrown1> But you can use any of the three styles to do an addition/replacement.
<bitbasher> huummm .. i take ur point .. but the arg list of object() is very diff than normal functions in that you can have objects as argments .. err .. but vector data structures are just as complex .. yeah . need to change that
<JordanBrown1> What vector-style is *really* good for is in conjunction with list comprehensions, to build up an object definition.
<bitbasher> that is why i call out the vector form as "being for" editing
<bitbasher> and .. $this is not yet implemented in a snapshit is it?
<JordanBrown1> no, it is not.
<bitbasher> i was playing with member functions
<JordanBrown1> o1 = object(a=1, b=2);
<JordanBrown1> echo(o1);
<JordanBrown1> echo(o2);
<JordanBrown1> o2 = object([ for (k = o1) [ str("x", k), o1[k] ] ]);
<JordanBrown1> takes an object, and produces a new object with all of the names having an "x" prepended.
<bitbasher> oh right .. but then they are not related anymore
<JordanBrown1> They aren't no matter what, but indeed they are not related.
<JordanBrown1> o2 = object(o1) makes a copy of o1; it is not related.
<JordanBrown1> Though because OpenSCAD values are immutable you can't actually tell.
<JordanBrown1> but we want the spouse to be an object, not just the name as as string, so later we remove it:
califax has quit [Remote host closed the connection]
<JordanBrown1> I don't understand this sentence, and in particular I don't understand the part about "be an object".
<bitbasher> you can tell .. playing with Fred, Wilma, Barney and Betty showed me that putting object references as members is never going to work
<JordanBrown1> It always works.
<JordanBrown1> Why do you think it doesn't?
<JordanBrown1> Fred = object( name="Fred", spouse="Wilma", friend=["Barney"] );
<bitbasher> ah .. so Fred and Wilma should both have spouse=(object) for each other
<JordanBrown1> s/friend/friends.
<bitbasher> but it can't be done
<JordanBrown1> OpenSCAD has no references.
califax has joined #openscad
<bitbasher> if does not work because when u define Fred, then Wilma .. Wilma can have spouse=Fred the object . .. but Fred is forever spouse="wilma"
<JordanBrown1> So you can easily make it so that Fred.spouse.name is "Wilma", but you can't infinitely follow references to Fred.spouse.spouse.spouse...
<bitbasher> one can replace spouse="name" with an object so
<JordanBrown1> use
<JordanBrown1> yes
<bitbasher> Wilma.spouse.spouse == Fred can be true
<bitbasher> err ... wrong
<bitbasher> Wilma.spouse == Fred can happen
<JordanBrown1> Yes. But Wilma.spouse.spouse == Wilma can never happen.
<bitbasher> but WIlma.spose.spouse is still going to be "WIlma" the string
<JordanBrown1> That depends on how you construct them. But there are no references.
<JordanBrown1> There are only copies.
<JordanBrown1> You *cannot* have a circular structure, because there are no references.
<bitbasher> exactly .. so even if you make Fred2=obejct( Fred, spouse=WIlma)
<bitbasher> you cannot get to the object spouse in WIlma to update it with the Fred2 object
<JordanBrown1> Fred2 is an object that looks a lot like Fred, and that includes a *copy* of Wilma.
<bitbasher> i tried real hard to get that to go :(
<bitbasher> yep .. and wilma is still thinking that Fred only know about the string "wilma"
<JordanBrown1> I think your Fred/Wilma example gets too complicated.
<bitbasher> it is .. i am going to chop down .. a lot
<bitbasher> the full example code is about 50 lines
<JordanBrown1> No, Wilma is an object that has a member "spouse" which in turn is an object that has a member "name" with value "Fred" and a member "spouse" with value "wilma".
<JordanBrown1> Fred, per se, is not in there. It is a copy of Fred.
snaked has joined #openscad
<bitbasher> so .. no references means shorter examples
<JordanBrown1> Giving an object as an argument preforms an implicit assignment of itself to the new object, it does not add the original's members individually.
<JordanBrown1> absolutely it does. If it doesn't, it's a bug.
<JordanBrown1> And it does.
<JordanBrown1> o1 = object(a=1, b=2);
<JordanBrown1> o2 = object(c=3, d=4);
<JordanBrown1> echo(object(o1,o2));
<JordanBrown1> ECHO: { a = 1; b = 2; c = 3; d = 4; }
<bitbasher> let me find my example
<JordanBrown1> In your object(Fred, Wilma) example what you are not understanding is that the members of Wilma individually replace the members of Fred.
<JordanBrown1> Since Wilma has the same members, the results is a copy of Wilma.
<JordanBrown1> Fred = object(name="Fred", spouse="Wilma", dog="Dino");
<JordanBrown1> Wilma = object(name="Wilma", spouse="Fred");
<JordanBrown1> echo(object(Fred, Wilma));
<JordanBrown1> ECHO: { name = "Wilma"; spouse = "Fred"; dog = "Dino"; }
<JordanBrown1> The explanation looks correct.
<JordanBrown1> Sorry, the explanation of the "later in list overrides" example looks correct.
<JordanBrown1> There is a good argument that we should *not* have made objects maintain order, because they really aren't intended as an ordered mechanism.
<JordanBrown1> But the output looks so much better if they are ordered.
<JordanBrown1> The rule that object() uses is that replacements replace the member in its original location.
<JordanBrown1> But it is better to say that although objects are displayed and enumerated in the order that the members were originally added, order is not guaranteed.
<bitbasher> that does some funny stuff
<JordanBrown1> I wouldn't include the "Functions as Members" section. Any value can be a member.
<bitbasher> that will be the place to explain $this and so on
<JordanBrown1> When and if we have a $this mechanism, yes.,
<JordanBrown1> But we don't.
<bitbasher> my testing of removals and additions showed that order is maintained .
<JordanBrown1> WRT that paste... without actually running it, it looks to me like yyy ends up as a copy of Betty.
<bitbasher> and when you reassign values without removal they appear in the list at the original position
<JordanBrown1> Isn't that what I said? "replacements replace the member in its original location."
<bitbasher> oh .. okay then .. misread
<bitbasher> and yyy is
<bitbasher> yyy = [{ name = "Wilma"; spouse = { name = "Betty"; spouse = undef; friends = { name = "Fred"; spouse = "wilma"; friends = ["barney"]; }; friends = ["Betty"]; }]; }
<JordanBrown1> It aborts at the undefined Barney.
<bitbasher> which by the name is of WIlma .. but notice that it starts with [ .. a square bracket so .. vector?
<JordanBrown1> But let me turn off abort-on-first-warning.
<bitbasher> i made barney a string
<bitbasher> yyy = [{ name = "Wilma"; spouse = { name = "Betty"; spouse = "barney"; friends = { name = "Fred"; spouse = "wilma"; friends = ["barney"]; }; friends = ["Betty"]; }]; },
<JordanBrown1> OK, yeah, something looks wrong there.
<bitbasher> Betty is noones spouse
<bitbasher> Fred is never a friend
<bitbasher> but is in a friends list
<bitbasher> is this worth a bug report?
<bitbasher> here is another one https://pastebin.com/9NmJDLrE
<JordanBrown1> I don't really have time to look into this in detail... getting on an airplane in approx 48h for a month vacation.
<JordanBrown1> I really shouldn't have spent as much time as I have, fun as it has been.
<bitbasher> good for you .. then thanks for your time giving feedback
<bitbasher> heh .. ranting for pleasure !! woo hoo
<bitbasher> i will post these two scripts aas a bug report .. someone can take a look while you are on the beach
<JordanBrown1> I think the bug is in how the values are string-ified rather than in how they are constructed.
<bitbasher> BRB
<JordanBrown1> Somehow the open marker from Betty's friends list is getting emitted at the start.
<bitbasher> ah .. .. i wonder if str() will help
<JordanBrown1> https://bpa.st/IL2Q is a pretty minimal demonstration.
<JordanBrown1> str() does not change the picture, and I would be surprised if it did since it and echo use the same mechanism.
<bitbasher> i guessed .. did something diff
<bitbasher> zzz = [for(y=yyy) [y,yyy[y]]]; echo(zzz=zzz);
<bitbasher> got
<bitbasher> ECHO: zzz = [["name", "Betty"], ["spouse", "barney"], ["friends", [{ name = "Wilma"; spouse = { name = "Fred"; spouse = "wilma"; friends = ["barney"]; }; friends = ["Betty"]; }]]]
<bitbasher> little hard to parse out but that looks like a correct clone of Betty
<JordanBrown1> I believe it is, just being reported incorrectly.
<bitbasher> anyway .. i need to get to sleep
<bitbasher> thx again for your help .. umm did u see the forum posts .. i had questions there too .. render() is back in the Dark Mystery group for me after TPaul got upset with me
<bitbasher> over this bug report https://github.com/openscad/openscad/issues/6046
<JordanBrown1> Yeah, well, you keep trying to read something into it that just isn't there.
<bitbasher> NM .. i see your reply on that now
<JordanBrown1> It isn't defined to produce any particular mesh, just a correct mesh.
<JordanBrown1> Just like F6.
<JordanBrown1> Anyhow, I need to shut down now. Later.
<bitbasher> laters
<JordanBrown1> A correct mesh that correctly represents the shape, that is.
<bitbasher> go away man ... step away from the keyboard .. he heh
<sculptor> bitbasher - is that a milder term for bitbanger
<sculptor> for the purpose of sounding less creepy
<bitbasher> lol .. it started as bytebasher long ago .. but that name was taken on Sourceforge so i took bitbasher
<bitbasher> when github came along i stayed with it
<sculptor> nice
<bitbasher> i also do minecraft with bytebasher
<bitbasher> but strategy games and FPS i go by giftig
<bitbasher> if you know dutch ? i live in Flanders in Belgium so that means Poison or Poisonous
<sculptor> no but i know flanders from the simpsons
<sculptor> interesting
<bitbasher> lol .. there are a few folks named Flanders indeed
<sculptor> i liked the movie: in bruges
<bitbasher> Bruges is about 30 min west of me here in Gent
<bitbasher> but i have not seen the movie
<sculptor> there was a place called f...ink, in austria
<sculptor> they recently renamed it
<sculptor> f...ing
<bitbasher> there was also the Monument Men .. Hugh Bonneville's character got killed in the cathedral in Bruges
<bitbasher> heh heh
<bitbasher> but now .. i need to sleep .. see you later
<sculptor> it's quarter to 4 am after all
<sculptor> nitey nite
<sculptor> i just woke up
<bitbasher> r u in CET also?
<bitbasher> Central EU Time i mean
<sculptor> CEST atm
<sculptor> utc+2
<sculptor> yes in europe, but not in eu
<bitbasher> just using EU as a short form
teepee has quit [Remote host closed the connection]
teepee has joined #openscad
<bitbasher> night
<sculptor> o/
teepee has quit [Quit: bye...]
mmu_man has quit [Ping timeout: 276 seconds]
teepee has joined #openscad
bitbasher has quit [Ping timeout: 240 seconds]
<gbruno> [github] mrufsvold opened issue #6047 (Crash when doing difference on object scaled to 0) https://github.com/openscad/openscad/issues/6047
<gbruno> [github] mrufsvold edited issue #6047 (Crash when doing difference on object scaled to 0) https://github.com/openscad/openscad/issues/6047
howiemnt has quit [Remote host closed the connection]
howiemnt has joined #openscad
gehel has quit [Server closed connection]
gehel has joined #openscad
sculptor has quit [Ping timeout: 260 seconds]
<gbruno> [github] jordanbrown0 opened issue #6048 (Bad output converting object to string) https://github.com/openscad/openscad/issues/6048
Guest17 has joined #openscad
Guest17 has quit [Client Quit]
aiyion has joined #openscad
Alexer has quit [Server closed connection]
Alexer has joined #openscad
<gbruno> [github] gtoal opened issue #6049 (animate: use cached images?) https://github.com/openscad/openscad/issues/6049
<gbruno> [github] jordanbrown0 closed issue #6046 (render() module fails silently in some conditions of scope) https://github.com/openscad/openscad/issues/6046
pie_ has joined #openscad
castaway has quit [Ping timeout: 248 seconds]
bitbasher has joined #openscad
bitbasher has quit [Changing host]
bitbasher has joined #openscad
califax has quit [Remote host closed the connection]
califax has joined #openscad
teepee_ has joined #openscad
teepee has quit [Ping timeout: 244 seconds]
teepee_ is now known as teepee
<gbruno> [github] t-paul closed issue #6049 (animate: use cached images?) https://github.com/openscad/openscad/issues/6049
teepee has quit [Remote host closed the connection]
bozo16 has joined #openscad
teepee has joined #openscad
bitbasher has quit [Ping timeout: 260 seconds]
mmu_man has joined #openscad
snaked has quit [Quit: Leaving]
Guest23 has joined #openscad
bitbasher has joined #openscad
Guest23 has quit [Quit: Client closed]
howiemnt has quit [Remote host closed the connection]
howiemnt has joined #openscad
ToAruShiroiNeko has quit [Ping timeout: 276 seconds]
mmu_man has quit [Ping timeout: 252 seconds]
mmu_man has joined #openscad
mmu_man has quit [Ping timeout: 240 seconds]
mmu_man has joined #openscad
mmu_man has quit [Ping timeout: 252 seconds]
mmu_man has joined #openscad
ToAruShiroiNeko has joined #openscad
bitbasher has quit [Ping timeout: 245 seconds]
guso78k has joined #openscad
guso78k has quit [Quit: Client closed]
mmu_man has quit [Ping timeout: 252 seconds]
bitbasher has joined #openscad
mmu_man has joined #openscad
Guest69 has joined #openscad
Guest69 has quit [Client Quit]
Fleck has left #openscad [Once you know what it is you want to be true, instinct is a very useful device for enabling you to know that it is]
Guest17 has joined #openscad
Guest17 has quit [Client Quit]
mmu_man has quit [Ping timeout: 260 seconds]
J25k has joined #openscad
mmu_man has joined #openscad
little_blossom has quit [Ping timeout: 252 seconds]
little_blossom has joined #openscad
califax has quit [Quit: ZNC 1.8.2 - https://znc.in]
califax_ has joined #openscad
califax_ is now known as califax
teepee_ has joined #openscad
teepee has quit [Ping timeout: 244 seconds]
teepee_ is now known as teepee
bitbasher has quit [Ping timeout: 260 seconds]
sculptor has joined #openscad