Re: Why does wrapping the code in a top level procedure make it faster?

2020-07-01 Thread juancarlospaco
Otherwise all variables are global. I dont know whats a cinoaiker.

Re: Connection-Pooling Compile-Time ORM

2020-07-01 Thread jasonfi
What does a multi-line where clause look like? I couldn't find an example, especially of a complex where clause, possibly using exists as one of the lines. It's a pity the from keyword needs to be in single quotation marks. I was trying to think of an alternative (e.g. source), but then it

Why does wrapping the code in a top level procedure make it faster?

2020-07-01 Thread didlybom
As the title of this thread says, I’ve seen many recommendations in this forum to wrap your code in a top level “main” procedure. Why does that make it faster and why can’t the cinoaiker make that optimization automatically for you?

Re: NvP: s = s & 'x'

2020-07-01 Thread HashBackupJim
I see, has to be like this: proc main() = var s: string proc `+`(a:string|char, b:string|char): string = a & b template fused2{a = `&`(a,b)}(a:var string,b:string|char) = a.add(b) template fused4{a = `+`(a,b)}(a:var

Re: NvP: s = s & 'x'

2020-07-01 Thread HashBackupJim
That was cool, so I thought I'd try the same thing with +: ms:nim jim$ cat strfused.nim proc main() = var s: string template fused2{a = `&`(a,b)}(a:var string,b:string) = a.add(b) template fused3{a = `&`(a,b)}(a:var string,b:char) = a.add(b)

Re: Change Nim colour on GitHub

2020-07-01 Thread jibal
#FFFE66 is available.

Re: NvP: s = s & 'x'

2020-07-01 Thread HashBackupJim
Hey thanks, this is interesting, although it threw me at first because it ran in .01s and used 4MB of RAM. After scratching my head a bit I realized you were doing 1M loops instead of 100M. :-) The template version ran in .69s on my machine, while str1c, which should be the same thing, runs in

Re: NvP: s = s & 'x'

2020-07-01 Thread shirleyquirk
var s: string template fused2{a = `&`(a,b)}(a:var string,b:string) = a.add(b) for _ in 0..1_000_000: s = s & "x" echo len(s) Run that was the secret! dumpTree was my friend, needed to get the AST to match precisely

Re: NvP: s = s & 'x'

2020-07-01 Thread shirleyquirk
var s: string proc `:=`(a:var string,b:string) = `=`(a,b) template fused{`:=`(a,`&`(a,b))}(a:var string,b:string) = a.add(b) #template fused2{`=`(a,`&`(a,b))}(a:var string,b:string) = a.add(b) for _ in 0..1_000_000: s := s & "x" echo len(s) Run

Re: Tables and Import

2020-07-01 Thread TinBryn
I think try to make module names plural by convention as well, in the standard library the module containing `Table` is `tables`. I would name the module `images`