Timothee Cour

Results 450 comments of Timothee Cour

@xflywind the proper fix should be to handle `case x of 1 .. 65536:` similarly to C codegen, without generating code bloat, eg transforming it to: `if x >= 1...

@xflywind > I have considered this solution but a bit hard. Nim compiler outputs JS code by concatating strings. If stmt should be put in the default branch and in...

this issue wasn't properly fixed, I'm re-opening. This: ```nim proc main(a: char) = case a of 'a'..'z', 'A'..'Z': echo "alpha" of '0'..'9': echo "digit" else: echo "other" main('x') ``` produces...

workaround: library defined `case`, refs https://github.com/nim-lang/RFCs/issues/332#issuecomment-778448264 ```nim import macros macro `case`*(a: string, branches: varargs[untyped]) = ... case x: of 10..13: ... else: ... ``` but this would require some `import...

> I made a patch at jsgen(when the number of branchs exceeds 1000, compiler generates if else statement sounds good, do you have a WIP PR? why 1000 instead of...

> Does this work across scopes? For example: yes, there are several examples dealing with variables across nested function scopes in tviewfroms.nim (eg, search for `example1`); it works across any...

> But there's nothing to prevent the Nim compiler from inserting destructors at the end of a block for variables present only in the block's scope, right? a destructor can't...

> Please be aware that return/result is not the only way to pass information up the call chain, contrived example: I know; note that your example is correctly handled (gives...

> The pointer of a ref is stackallocated. And if the ref is destroyed the pointer will point into oblivion. as I said above, please provide a complete example for...