Too many harsh words, I'm closing this thread.
Well, it is a domain-specific language for parsing text, so if you are _not_
familiar with the subject it will look unreadable, but at the same time it is
still much easier to write and maintain compared to dozens of handwritten
loops, checks and conditions like `if str[idx] == '='`.
I don't even know how to reply to this honestly... Your JSON fetish isn't
shared by everyone.
Yes I have maintained code I wrote years ago - I do it all the time at work. I
also maintain code other people wrote years ago. I see little point to your
argument.
I think you have a very narrow
This is a pretty ridiculous claim and I think the only place where this even
comes close to being true is in the web development world. Nim is a systems
programming language, or at least it's supposed to be. It is not supposed to be
NodeJS or whatever your favorite web framework is.
I don't
le industry experience has arrived
Macros make code much easier to read. Consider this example from npeg:
let parser = peg("pairs", d: Dict):
pairs <- pair * *(',' * pair) * !1
word <- +Alpha
number <- +Digit
pair <- >word * '=' * >number:
d[$1] = parseInt($2)
Run
Imagine
Eh, python did it for urllib.
Though python I'd probably a bad model to follow for version transitions.
Strictly speaking, the `proc` that convert any type to `JsonNode` is named `%`,
not `%*`. `%*` is a macro that let you write inline json in a nature way.
Alternatively, you can write like this.
import json
let j1 = {"j": %10,"s": %20,"o": %100,"n": %5000}
echo %j1
Templates are literally C `#define`, but without all the pitfalls and
consistent with the rest of the language.
> But it is VERY useful to have JSON in stdlib,
Yeah, the **std** namespace is precious, and no one wants to see `json2`,
`json3`, etc. You can't make an omelette without breaking a few eggs.
But it is VERY useful to have JSON in stdlib, I would rater deprecate less used
stuff like `std/logic` or `std/inotify`...
> Then its time to Fix it, even if it means breaking changes...
No need to break anything, deprecate the module and link to an alternative,
recommended package.
> Almost nothing in json.nim aged too well. :-)
Then its time to Fix it, even if it means breaking changes...
Templates are IMO the simplest form of metaprogramming in Nim as it's just code
substitution.
If you're concerned with debugging you can add an extra piece of complile-time
logic into the templates that only executes / gets put into the resulting
binary when you define something like
> Which is obviously unreadable and very easy to forget what it means.
Not really, once you know what it means it's quite readable, but it requires
that you familiarize yourself with the tools you're using. Besides, when you
see something that looks suspiciously much like json with some
yes.
`template json*(t): JsonNode = %* t`
badabing, crisis averted.
Almost nothing in `json.nim` aged too well. :-)
The idea back then was "toJson is more common than modulo, so I'd rather use %
for that operation". But `%` only worked on simple values (integers, values),
so in order to turn "anything" you would use `%*` which read like "%/toJson but
17 matches
Mail list logo