open question about equals-equals (==) usage in decimal library

2021-01-23 Thread Araq
We now also have `almostEqual` as an operation, but maybe that name doesn't fit decimals.

open question about equals-equals (==) usage in decimal library

2021-01-23 Thread ElegantBeef
I'd personally say use `=^` or `^=` for magnitude comparison, as `^` indicates raising to the power, which as you know is how scientific notation is done. Knowing that it sorta reads as "x equal to power of y".

Why aren't the built-in math procs (`+`, `-`, `*`, ...) procvars?

2021-01-23 Thread shirleyquirk
at first approximation templates are like c macros, (without the footguns). they can for sure get complicated, but at a high level, it's copy/paste. so without the {.gensym.} Run you get a redefinition error, because you define a proc Run for addition, the

Why aren't the built-in math procs (`+`, `-`, `*`, ...) procvars?

2021-01-23 Thread RainbowAsteroids
Thanks showing me how! I'm a bit confused on what `{.gensym.}` means though. I tried reading the manual section about template hygiene, and I didn't fully comprehend it. Maybe because I don't fully understand templates in general.

Best showcase of tests in Nim standard library?

2021-01-23 Thread Clonk
It's not perfect but it's there.

Current state of list comprehison in Nim

2021-01-23 Thread deech
I like how all these langs are discovering monads and some form of do/for/yield notation.

Ignore part of tuple without warnings

2021-01-23 Thread ynfle
I'm 99% sure `gensym` is short for "generated symbol". It refers to a symbol that was the end of it's "name" added to prevent collisions with other names because it was generated in a template or macro.

Best showcase of tests in Nim standard library?

2021-01-23 Thread ynfle
Ya but AFAIK there isn't any documentation on `testament`

Why aren't the built-in math procs (`+`, `-`, `*`, ...) procvars?

2021-01-23 Thread shirleyquirk
it's not perfect, but here's one way: template operation(op: untyped, name: string): proc() = proc fn(){.gensym.} = var x{.inject.}: float = getNumber("Input the first number: ") var y{.inject.}: float = getNumber("Input the second number: ") echo()

Ignore part of tuple without warnings

2021-01-23 Thread doofenstein
those terms and phrases come all directly from the Nim manual, that's why you probably see them a lot here

open question about equals-equals (==) usage in decimal library

2021-01-23 Thread Araq
There is a criterion that determines what to do: You want `==` to be the _exact_ comparison so that there are no surprises when you store these numbers as keys for a hash table. The equivalent operator should probably be written as `=~`.

open question about equals-equals (==) usage in decimal library

2021-01-23 Thread JohnAD
Sometimes the question of "what is more intuitive" is not easily answered; so I'm asking the overall community for an opinion: how to handle the "equivalence" operator for the decimal library I'm writing. First a bit of background: in a typical decimal library, one not only stores the decimal d

Nim compiler follows symbolic links too eagerly

2021-01-23 Thread HJarausch
I don't like to flood mylib.nim with `when `

Client-side JS with Nim

2021-01-23 Thread Mangosteen
I dont understand

Nim compiler follows symbolic links too eagerly

2021-01-23 Thread xigoi
Why do you need to do this? Wouldn't it be better to use compiler switches?

How to generate Named Tuples on the fly?

2021-01-23 Thread alexeypetrushin
Thanks, solved let log = Log.init("Finance") log .with((symbol: "MSFT", currency: "USD")) .info("getting prices for $symbol in $currency") Run Supporting code ([full code](https://forum.nim-lang.org/postActivity.xml) if anyone interested)

How to generate Named Tuples on the fly?

2021-01-23 Thread b3liever
just do %(age: 35, pi: 3.1415) and it converts it to JsonNode.

Nim compiler follows symbolic links too eagerly

2021-01-23 Thread HJarausch
The former, i.e. MyLibDebug.nim is in the current folder where the source which imports mylib lives, as well.

Nim compiler follows symbolic links too eagerly

2021-01-23 Thread Stefan_Salewski
Have you tried cd whereMyModule lives ln -s MyLibDebug.nim mylib.nim import mylib Run

Nim compiler follows symbolic links too eagerly

2021-01-23 Thread HJarausch
I like to use something like the following (on Linux) `ln -s MyLibDebug.nim MyLib.nim` or `ln -s MyLibInTest.nim MyLib.nim` and then somewhere `import MyLib.nim` but this fails with `invalid module name: MyLib.nim` This feels like a bug.

Morgenstern-ish documentation

2021-01-23 Thread drkameleon
I've been told that my visual observation skills are not very strong... haha

Morgenstern-ish documentation

2021-01-23 Thread Sixte
Well, it is there since 2015 at least, it might have been there back then even longer.

Morgenstern-ish documentation

2021-01-23 Thread drkameleon
OK, I decided to post a totally not-serious off-topic message to whoever decided to make a Rammstein [verse-drop in the documentation](https://nim-lang.org/docs/tut1.html), which I was going through again... You made my day! :)

How to generate Named Tuples on the fly?

2021-01-23 Thread greenfork
Different 3rd party JSON libraries have different "nice and compact" syntax, you can choose the one you like. Not everything has `%*{ "age": 35, "pi": 3.1415}` syntax

Ignore part of tuple without warnings

2021-01-23 Thread holgerschurig
> gensymmed Both you and ElegantBeef uses this term in a forum where a lot of newbie are in. Is it possible to sound less like a CS professor here? :-) I'm also quite sure not everyone knows "to maintain scope hygiene" is or means, or why one personally needs to care about it and this isn't som

Admin for web app

2021-01-23 Thread alexeypetrushin
Hmmm, I used GraphQL with React.JS. I like the idea behind it, but its current implementation feels a bit verbose, too much boilerplate code to write...

How to generate Named Tuples on the fly?

2021-01-23 Thread alexeypetrushin
> You can choose a 3rd-party library for JSON which syntax you like most I mean - it's not about JSON (I know how to convert Nim object to JSON). The question is - how to generate Named Tuple, Object, or Flexible-Object-Like-Container (like JsonNode) with nice and compact syntax.

How to generate Named Tuples on the fly?

2021-01-23 Thread greenfork
You can choose a 3rd-party library for JSON which syntax you like most

Admin for web app

2021-01-23 Thread vinyll
I guess a safe bet would be a client UI and a GraphQL API. GraphQL has that ability to provide an API introspection for fields and methods, therefore a UI could be server agnostic and cross languages.

Is there a way to use question mark in my proc names?

2021-01-23 Thread holgerschurig
> I would like to use the typical lisp style `(defun is-large-p (foo) ...)` I'm not into Lisp, only into Emacs, and there these tests are called "predicate" and more often than not have a trailing `p` or `-p`) in their names. In any case, I wouldn't use Lisp as an example on how to name things.

How to generate Named Tuples on the fly?

2021-01-23 Thread alexeypetrushin
I mean - "structured" in a way that log messages are not strings, but have "structure" \- as data objects. Not in terms of structured in Nim types. > object variants if you know how exactly different log messages are going to > differ No I don't know, the point is to generate it on the fly. So

How to generate Named Tuples on the fly?

2021-01-23 Thread greenfork
You can have "structured" data as an object and then use another field as JSON for "unstructured" data type LoggingData = object id: int time: Time level: LogLevel info: JSON Run

Current state of list comprehison in Nim

2021-01-23 Thread greenfork
Yeah, I also like your idea about no-IO allowed. Would be interesting to see as well, especially since we already have strictFuncs

Current state of list comprehison in Nim

2021-01-23 Thread Araq
And don't misunderstand me -- the Elixir version of your example _is_ nice, because it's shorter than Nim's and yet _still_ very readable. (But not more readable, the fact that three nested loops are involved is easier to see in Nim and is important to see when you care about the "big O" behavio