Sunday, 2019-09-08

*** tpb has joined #tomu00:00
*** xkapastel has quit IRC01:26
*** rohitksingh has joined #tomu02:16
*** rohitksingh has quit IRC02:24
*** cdmatter has joined #tomu04:16
*** rohitksingh has joined #tomu06:49
*** rohitksingh has quit IRC07:21
*** cdmatter has quit IRC07:22
*** rohitksingh has joined #tomu07:24
*** cdmatter has joined #tomu07:41
*** ppisati has quit IRC09:02
*** ppisati has joined #tomu09:11
*** rohitksingh has quit IRC09:28
*** xkapastel has joined #tomu10:11
*** cdmatter has quit IRC11:23
*** cdmatter has joined #tomu11:57
*** bluebugs has joined #tomu12:37
*** bluebugs has joined #tomu12:37
*** cedric has quit IRC12:38
*** xkapastel has quit IRC12:50
*** js`xmpp has joined #tomu13:06
*** xkapastel has joined #tomu14:38
*** emeb has joined #tomu14:40
MadHackerovf: Miss out the wrap() in that example and it fails to build./18:20
MadHackerThere are less obvious failure modes too, where it just generates *wrong* output as a result of the early-exit behaviour of "and" (vs. &).18:20
MadHackerI think if you avoid "and" and "or", all the failure modes result in an exception, though.18:22
MadHackerUse & and | and you should be good.18:22
ovfMadHacker: thanks! not specifically migen's fault, then -- `and` and friends in python are syntactic sugar, not binary operators (x and y is special syntax for !x?0:y in c)19:11
MadHackerWell, it's migen's in the sense that it's a python binding, but yes, it's something unfixable.19:12
MadHackerIn older python you could abuse __coerce__ to try and stop that happening (by blocking any coercion to bool) but I think __coerce__ went away in 3.19:12
MadHackerI can live with it, personally.19:13
MadHackerNeeding wrap() on the simpler cases, however, is just plain weird.19:13
ovfyes, it's definitely an expected downside of embedding an ast builder in a general purpose language, but i didn't have doubts about that. :-)19:13
MadHackerAs you say. :)19:13
*** rohitksingh has joined #tomu19:16
ovfyour paste seems to have perished but i thought you shouldn't have needed wrap() there as the lhs of both subexpressions was a migen.Signal?19:16
MadHacker https://pastebin.com/pUw0QKUu have a fresh paste.19:17
tpbTitle: jamie@t2:/tmp$ cat minimal_demo.py from migen import * from migen.fhdl.v - Pastebin.com (at pastebin.com)19:17
MadHackerD'you know, I think I'm wrong. I think it was always just an operator precedence issue.19:19
MadHackerIt's not the wrap, it's the (). <embarrassed>19:19
MadHackerYeah. The way the precedence rules work, minus the wrap() and the brackets, you end up with 7 & self.B in the middle, and that's why you get the TypeError about converting a Migen value to a boolean.19:21
MadHackerHm, maybe not? Still wrong.19:21
MadHackerNo, it's even weirder. I don't know now. https://pastebin.com/7xjvJdZG19:23
tpbTitle: [Python] >>> from migen import Signal >>> a = Signal() >>> b = Signal() >>> a == 7 (at pastebin.com)19:23
MadHackerhttps://pastebin.com/LKw0MNgh more complete.19:24
tpbTitle: [Python] >>> a = Signal() >>> b = Signal() >>> a == 7 (at pastebin.com)19:24
MadHackerIt's even weirder.19:24
ovf>>> (a==7&b).op19:48
ovf'=='19:48
ovfcomparison operators have lower precedence than arithmetics (like &)19:49
ovfa==7&b==7 is in fact python's chained comparison (you usually use it in slightly more useful form, like 2<x<5). another syntactic shortcut (like and) that makes your migen experience miserable. :-)19:50
*** rohitksingh has quit IRC20:00
*** xkapastel has quit IRC20:18
*** rohitksingh has joined #tomu20:19
*** pollo has quit IRC20:21
*** pollo has joined #tomu20:22
*** rohitksingh has quit IRC21:48
*** js_ has joined #tomu21:51
*** js has quit IRC21:52
*** js_ is now known as js21:52
*** andi- has quit IRC22:03
*** techman83 has quit IRC22:10
*** techman83 has joined #tomu22:10
*** feuerrot has quit IRC22:11
*** andi- has joined #tomu22:11
*** feuerrot has joined #tomu22:15
*** emeb has quit IRC22:40
MadHackerovf: That makes sense, but the net effect is still that it's really quite surprising when it gets it wrong. :)22:40
*** rohitksingh has joined #tomu22:44
ovfindeed. at least in this case, you've got a compile-time error (although rather cryptic), not a silent failure. i generally find operator precedence confusing and unnecessary, and one's better off with all operators having the same precedence: back where i come from, 2*2+2 is 8 (and 2+2*2 is 6).23:03

Generated by irclog2html.py 2.13.1 by Marius Gedminas - find it at mg.pov.lt!