Zippy: a dependency-free Nim implementation of deflate, gzip, zlib, zip

2020-11-08 Thread slonik_az
> @treeform This lib should be installed by default as part of nim install. I think `fusion` is a good place to put this code into.

conditional expressions don't work in a formatted string

2020-11-08 Thread xigoi
Maybe you could use the ternary operator from [Elvis](https://nimble.directory/pkg/elvis)? echo fmt"{(x > 0) ? 7 ! 0}" Run

strange syntax - please explain

2020-11-08 Thread xigoi
No. Parsing is done before semantic analysis.

Zippy: a dependency-free Nim implementation of deflate, gzip, zlib, zip

2020-11-08 Thread treeform
It's just 1% slower then regular zlib, but in pure nim. This is a big deal. Does not require zlib1.dll or C. zlib had like 20 years of effort put into optimizing it, with nim you were able to achieve nearly same perf nim much shorter time. You have solving the HTTP gzip'ed payload problem. This

Zippy: a dependency-free Nim implementation of deflate, gzip, zlib, zip

2020-11-08 Thread jbcomps
This is awesome! Thank you for your work!

strange syntax - please explain

2020-11-08 Thread Sixte
If you prefer a terse syntax, write simply: `let Reihe = RIn-1` But I'd visualize a `let Reihe = RIn -1` directly as an application of RIn to the negative number -1. So, the Nim lexer supports both terse (condensed) syntax and wide syntax with space. If space is available, write binops with spa

Zippy: a dependency-free Nim implementation of deflate, gzip, zlib, zip

2020-11-08 Thread guzba
Hey all, just wanted to share the result of the work I've done recently here in the hope it helps people. Zippy / is new and pure Nim implementation of the deflate compression algorithm and the gzip and zlib data formats. I hope this will save people a bunch of t

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread slonik_az
If for your purposes a function-level scope of the "reference variable" is enough, you can simply use `var` modifier to the formal argument like this type Abc = object a, b: int c: array[10, int] proc foo(r: var Abc) = r.a = 42 r.b = 24

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread timothee
yup, {.byaddr.} is the answer

Has anyone wrapped zlib or reimplemented deflate?

2020-11-08 Thread guzba
I have a pure Nim implementation of deflate / zlib over here: also on nimble as zippy. I'm actively working on the library. Right now it is comparable to zlib default level in both speed and compression.

strange syntax - please explain

2020-11-08 Thread HJarausch
I don't like it either, but such things happen. I'd prefer a better error message, as well. Still, why can't the compiler "see" that RIn is just an integer and cannot be a proc in any case?

strange syntax - please explain

2020-11-08 Thread SolitudeSF
because when you add Rln proc in other place in same module/imported modules, this seemingly unrelated piece of code will stop compiling or will give unpreditctable results. i bet you would be even more frustrated is that how it worked.

FastCGI vs HTTP server?

2020-11-08 Thread dom96
I doubt http/2 and/or http/3 (QUIC) makes sense for most Nim applications. You should be reverse proxying Jester using nginx (or another http server) anyway, and I'm sure it can take care of HTTP/2 for you (as well as http/3 too). Also, if you're deploying your site to the world you'd likely wan

strange syntax - please explain

2020-11-08 Thread moigagoo
Well you don't have Nim's flexible function call syntax in a dozen other programming languages. If using this particular code formatting is crucial to you, Nim is probably not your choice. On a personal note, I find this code style absolutely ugly and actually like that the Nim compiler wouldn'

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread Yardanico
I'm surprised that no one mentioned which should be the exact alternative to that C++ feature.

strange syntax - please explain

2020-11-08 Thread HJarausch
In a dozen of other programming language the compiler is smart enough to differentiate between a monadic and dyadic operator. The compiler is able to "see" that Rin is not a procedure. Oh dear!

strange syntax - please explain

2020-11-08 Thread haxscramper_
This particular error was caused by method call syntax - because you can omit parenthesis around `functionCall arguments`, `RIn -1` got parsed as `RIn(-1)` and not `RIn - 1`. As for the list of "pitfalls" \- the only thing that comes to mind is passing tuples to function calls `funcall(1, 2)` i

strange syntax - please explain

2020-11-08 Thread Hlaaftana
The manual [says](https://nim-lang.org/docs/manual.html#syntax-precedence): > Whether an operator is used as a prefix operator is also affected by > preceding whitespace (this parsing change was introduced with version > 0.13.0): > > echo $foo > # is parsed as > echo($foo) Same applies here. `R

strange syntax - please explain

2020-11-08 Thread hugogranstrom
I don't think it's so strange because they mean two different thing depending on if there is a space between the minus sign and the one. * "\- 1" mean "something minus 1" * "-1" means "negative 1" So when you write `RIn -1` it should be read "RIn neagtive 1" as Nim's function calling synt

strange syntax - please explain

2020-11-08 Thread HJarausch
Nim is full of surprises proc Zug(RIn:int) = let Reihe = RIn -1 Run gives Error: attempting to call routine: 'RIn' found 'RIn' of kind 'param' I couldn't believe it, after many trials I found that a space is needed in front of 1. What a strange syntax!

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread lqdev
Thanks for the correction, I'll edit my snippet.

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread cblake
Minor correction.. @lqdev meant to say `r.b` & `r.c[5]` (which do still work).

conditional expressions don't work in a formatted string

2020-11-08 Thread jrfondren
This works: echo &"{[0,7][int(x > 7)]}" Run I imagine the restriction is related to the `{}` format options that all involve colons (`:`), which are a feature. What I would actually do is assign a variable to the result of that conditional.

FastCGI vs HTTP server?

2020-11-08 Thread xflywind
`Jester` and `Prologue` could use http/2 too except Server push or so. http/2 is based on http1.0, so just configuring `nginx` should be enough.

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread doofenstein
fortunately views can put pointers back to their place. They're only very recently implemented and still experimental and thus this example below (which I think is correct) segfaults at runtime 🙁: {.experimental: "views".} proc test() = var x = 42 y: v

conditional expressions don't work in a formatted string

2020-11-08 Thread pietroppeter
Expressions containing ‘:’ do not work, see here:

conditional expressions don't work in a formatted string

2020-11-08 Thread cblake
See [this thread](https://forum.nim-lang.org/t/6250). I think it would not be hard to modify the embedded inline parser in strformat to allow internal `:`, and this has come up often enough that it might be a good first PR...

conditional expressions don't work in a formatted string

2020-11-08 Thread HJarausch
Unless I am missing something, the following Python-alike doesn't work import strformat let x=1 echo fmt"{if x > 0 : 7 else: 0}" Run neither does echo fmt"{(if x > 0 : 7 else: 0)}" Run Is this a feature? Is there a simple workaround

FastCGI vs HTTP server?

2020-11-08 Thread mrhdias
Thanks @xflywind, this is good news :-) This is the best example I found that shows the advantages of the http/2 over the http/1.1. Each square in the image is a connection to the server.

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread HJarausch
Many thanks! The big question: is it probably that experimental features stay or become even non-experimental?

FastCGI vs HTTP server?

2020-11-08 Thread xflywind
I think We will have `QUIC` support soon(at least wrapper support).

FastCGI vs HTTP server?

2020-11-08 Thread mrhdias
Creating an HTTP/1.1 web server is a simple and trevial task, so there are many web frameworks in Nim. But, writing a server from scratch or using a library for http/2 or http/3 is completely different. It is a huge task. You can check the libraries:

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread lqdev
Currently the only way of doing that is through the use of pointers. However, dereferencing is done automatically for fields, so this: type Abc = object a, b: int c: array[10, int] var a = Abc() r = addr a a.b = 10 a.c[5] = 3

Reference Variable (C++ jargon) - is there such a beast?

2020-11-08 Thread HJarausch
If I have to access something like A.M[k] (or an even more complicated "object") several times, I'd like to create a "reference variable" (C++ jargon) R to it such that changing R does change the "underlying" "object". I could define a pointer P to it and use P[] all over the time but that's a b