|
Python 3.10 introduced case statements. It’s the best version.
|
# ? Feb 22, 2022 08:38 |
|
|
# ? May 22, 2024 09:07 |
|
for/else seems plenty useful, but in exactly the same way goto is plenty useful. overly arbitrary control flow is what i'm saying.
|
# ? Feb 22, 2022 10:21 |
DoomTrainPhD posted:Python 3.10 introduced case statements. It’s the best version.
|
|
# ? Feb 22, 2022 11:19 |
|
but does it have for..case?
|
# ? Feb 22, 2022 11:20 |
eschaton posted:but does it have for..case? the what now
|
|
# ? Feb 22, 2022 11:21 |
|
python needs for...candles
|
# ? Feb 22, 2022 11:35 |
|
oh you want a what now, do you? so in verilog you get case statements like this: code:
code:
|
# ? Feb 22, 2022 11:42 |
|
BobHoward posted:oh you want a what now, do you? if more than one is true does it invoke both?
|
# ? Feb 22, 2022 14:16 |
|
BobHoward posted:oh you want a what now, do you? Will it do just x or x and y if they're both 1? Lmao just please don't tell me it will only do y
|
# ? Feb 22, 2022 14:17 |
|
is that synthesizable?
|
# ? Feb 22, 2022 14:22 |
|
BobHoward posted:oh you want a what now, do you? maybe i'm missing something here but this doesn't seem that wacky to me? it's weird if you're used to c/c++, where the switch statement takes any expression but the case statement only takes constant expressions, but it's not that uncommon in other languages to allow any expression in either place. it's just a fancy way of writing a bunch of "if a == b" clauses so it doesn't matter which order you put the operands in.
|
# ? Feb 22, 2022 16:04 |
|
leper khan posted:Will it do just x or x and y if they're both 1? Lmao just please don't tell me it will only do y Just x Don't see why it wouldn't be synthesizable, like TheFluff points out, it's basically just a bunch of else ifs chained together. HappyHippo fucked around with this message at 16:19 on Feb 22, 2022 |
# ? Feb 22, 2022 16:17 |
|
cinci zoo sniper posted:the what now the for case paradigm
|
# ? Feb 22, 2022 20:21 |
good god (i definitely can use that)
|
|
# ? Feb 22, 2022 20:23 |
|
leper khan posted:Will it do just x or x and y if they're both 1? Lmao just please don't tell me it will only do y seems like the right thing to do, tbh
|
# ? Feb 22, 2022 20:25 |
|
see also Duff’s device, which is basically while…case if you look at oldschool unix kernel, device driver, etc. code you might encounter it as a micro-optimization
|
# ? Feb 22, 2022 20:26 |
|
toiletbrush posted:you can do this in Swift, and it chooses the first match in swift sure, but for a logic description language it arguably would make at least as much sense to have all matching cases "happen" at once, but i guess that is not the way verilog does things.
|
# ? Feb 22, 2022 20:30 |
|
Sweeper posted:if more than one is true does it invoke both? IEEE 1800-2017 posted:The case_expression shall be evaluated exactly once and before any of the case_item_expressions. The case_item_expressions shall be evaluated and then compared in the exact order in which they appear. If there is a default case_item, it is ignored during this linear search. During the linear search, if one of the case_item_expressions matches the case_expression, then the statement associated with that case_item shall be executed, and the linear search shall terminate. If all comparisons fail and the default item is given, then the default item statement shall be executed. If the default statement is not given and all of the comparisons fail, then none of the case_item statements shall be executed. except... if you prefix the case statement with the "unique" keyword, this is an assertion that you think exactly one case item (not 0, not 2 or more) will match. this makes it safe to evaluate all branches of the case statement in parallel. this is quite useful for certain synthesizable constructs where you want to make the logic generated for each branch of the case fully independent from the rest, but it comes with some footguns. the synthesized HW is generated by assuming that you are correct to assert uniqueness, and won't do anything to protect you if multiple branches of the case statement match. in a simulation, the simulator will throw an error if multiple matches occur when the unique case statement is evaluated, so you better make sure your sim has adequate coverage and never throws that error.
|
# ? Feb 22, 2022 21:35 |
|
if i were designing a programming language i would simply evaluate all the arguments at the same time
|
# ? Feb 22, 2022 22:16 |
|
i feel like there's one of those formal proof languages that has the rule that if multiple branches match one is selected at random to be evaluated my mind keeps telling me it's related to z, but i can't find an example of control flow in that
|
# ? Feb 22, 2022 22:21 |
|
here's a rust quiz that's relatedRust code:
|
# ? Feb 22, 2022 22:43 |
|
Destroyenator posted:i feel like there's one of those formal proof languages that has the rule that if multiple branches match one is selected at random to be evaluated go does this with channels
|
# ? Feb 22, 2022 22:51 |
|
tinaun posted:here's a rust quiz that's related I got this correct lol, but I'm cheating because it comes up in haskell too. It is also a rustc warning! code:
gonadic io fucked around with this message at 22:57 on Feb 22, 2022 |
# ? Feb 22, 2022 22:53 |
|
swift doesn’t have that problem but i’m honestly not sure it was worth it because it’s sooo wordy having to write let in patterns
|
# ? Feb 23, 2022 01:58 |
|
Destroyenator posted:i feel like there's one of those formal proof languages that has the rule that if multiple branches match one is selected at random to be evaluated dijkstra's "guarded command language" in a discipline of programming featured loops and conditionals which were each a set of clauses with "guard" preconditions, and they were intended to select a matching guard nondeterministically. the only difference between a conditional and a loop is that conditionals must have one matching clause, whereas loops iterate as long as there is at least one matching clause Internet Janitor fucked around with this message at 03:38 on Feb 23, 2022 |
# ? Feb 23, 2022 03:35 |
|
rjmccall posted:swift doesn’t have that problem but i’m honestly not sure it was worth it because it’s sooo wordy having to write let in patterns oh no the horror you might have to use more characters to express something that someone might have to read, understand, and change 30 years from now
|
# ? Feb 23, 2022 05:27 |
|
whjust do what most MUMPS implementations do and what DCL does, and support using the minimum spelling that’s unambiguous at any point in the program!
|
# ? Feb 23, 2022 05:29 |
|
eschaton posted:whjust do what most MUMPS implementations do and what DCL does, and support using the minimum spelling that’s unambiguous at any point in the program! also applicable to cisco boxes sw t p v e 1,2,3
|
# ? Feb 23, 2022 06:25 |
|
Internet Janitor posted:dijkstra's "guarded command language" in a discipline of programming featured loops and conditionals which were each a set of clauses with "guard" preconditions, and they were intended to select a matching guard nondeterministically. the only difference between a conditional and a loop is that conditionals must have one matching clause, whereas loops iterate as long as there is at least one matching clause that was it, thank you!
|
# ? Feb 23, 2022 08:17 |
|
eschaton posted:oh no the horror you might have to use more characters to express something that someone might have to read, understand, and change 30 years from now i for one add a "/* let */" in every place it is syntactically allowed in my programs, to help the people in 30 years.
|
# ? Feb 23, 2022 10:55 |
|
Cybernetic Vermin posted:i for one add a "/* let */" in every place it is syntactically allowed in my programs, to help the people in 30 years. Knuth over here trying to solve illiteracy through writing.
|
# ? Feb 23, 2022 14:44 |
|
casema balls
|
# ? Feb 23, 2022 15:28 |
|
https://github.com/Kindelia/HVMquote:High-order Virtual Machine (HVM) is a pure functional compile target that is lazy, non-garbage-collected and massively parallel. It is also beta-optimal, meaning that, in several cases, it can be exponentially faster than most functional runtimes, including Haskell's GHC. I don’t know enough about Haskell or beta optimality or higher-kinded anything to really evaluate it, but I do know that cherry-picked benchmarks can even make a compiler I write look good is this
|
# ? Feb 25, 2022 20:19 |
|
idk that depends.... is it highly opinionated?
|
# ? Feb 25, 2022 20:25 |
|
I'm sigma-optimal
|
# ? Feb 25, 2022 20:27 |
|
i mean you can do a lot if you just completely assume purity. even haskell compilers have to model effects
|
# ? Feb 25, 2022 21:10 |
|
This came up with STM too, with haskell (and co) the only ones to be able to implement it without insane footguns of: literally any side effect in code.
|
# ? Feb 25, 2022 21:46 |
|
sigma nutts
|
# ? Feb 26, 2022 00:35 |
|
Subjunctive posted:https://github.com/Kindelia/HVM the author is excited about something or other that enables even higher levels of typewank than have previously been achieved in efficient computations. there will probably be a shitload of publications citing this but aside from that who knows
|
# ? Feb 26, 2022 03:09 |
|
|
# ? May 22, 2024 09:07 |
|
Poopernickel posted:sigma nutts new ux people at work have decided to go from zepplin (which is good) to figma (which sucks) so figma balls
|
# ? Feb 26, 2022 03:10 |