what is the nim equivalent to the python None type

2024-03-13 Thread isaiah
`type Point* = object x,y,a,b: int func initPoint(x,y,a,b:int):Point = result.x = x result.y = y result.a = a result.b = b if some(x).isNone and some(y).isNone: return if not(y^2 == x ^ 3 + a*x+b): raise newException(ValueError, fmt"({x}, {y}) is not on the curve")` Run

what is the nim equivalent to the python None type

2024-03-13 Thread isaiah
`import std/[strformat, options] import math type TypeError = object of ValueError type Point* = object x,y,a,b: int func initPoint(x,y,a,b:int):Point = result.x = x result.y = y result.a = a result.b = b if some(x).isNone and some(y).isNone: return if not(y^2 == x ^ 3 + a*x+b): raise newExcept

what is the nim equivalent to the python None type

2024-03-13 Thread isaiah
`type Point* = object x,y,a,b: int func initPoint(x,y,a,b:int):Point = result.x = x result.y = y result.a = a result.b = b if some(x).isNone and some(y).isNone: return if not(y^2 == x ^ 3 + a*x+b): raise newException(ValueError, fmt"({x}, {y}) is not on the curve") ` Run

Debugging with GDB?

2024-03-13 Thread mszs
I checked online and found some instructions on how the use GDB with nim. So, I'm using `--debugger:native` before starting `nim-gdb` and starting debugging. But then I'm here: Temporary breakpoint 1, main (argc=3, args=0x7fffd1f8, env=0x7fffd218) at /home/marko/.c

A template to emit ARM asm

2024-03-13 Thread dwhall256
When I turned all the templates into inline procs, then it no longer read from the register a second time. I also read the gcc's docs about the asm statement in greater detail and fixed one register modifier and discovered how to convert Nim static args to an assembly immediate operand. With the

A template to emit ARM asm

2024-03-13 Thread dwhall256
Good suggestion, Peter. It makes sense. I tried turning `AHB1ENR` to an inline proc. It resolved the error, but the procedure was called a second time after the `asm` statement, overwriting the modification to the variable. So a tried turning more of the templates into inline procs. I got someth

Nim for Beginners video series discussion thread

2024-03-13 Thread Kiloneie
# [Nim for Beginners List Comprehensions with sugar.collect vs Python's List Comprehensions](https://youtu.be/avPVtGUd-oQ) **Video description:** In this video we will go over sugar.collect, it's pros and cons, and compare it against Python's list comprehensions with some benchmarks. [Link to

Active Keto Gummies AuNz

2024-03-13 Thread dyhfujgh
Active Keto Gummies AuNz

A template to emit ARM asm

2024-03-13 Thread PMunch
Remember that templates are code substitution. I think what's going on here is that `AHB1ENR` returns `volatileLoad(RCC_AHB1ENR)`, this is a statement which resolves to the type `RCC_AHB1ENR_Val`. Now in `GPIOAEN` this is used once in the emit statement which causes a read, then it is passed on

A template to emit ARM asm

2024-03-13 Thread dwhall256
No luck. It had the same error message, redeclaration of the variable. Here's the whole code for context. The other templates may be affecting the outcome of the one I quoted previously in this discussion. Solving this isn't critical. I have a working implementation in Nim. I am trying for an op

Custom type conversion

2024-03-13 Thread demotomohiro
Nim doesn't have C++ like constructors. Defining procedures like `createFoo` or `initBar` is the popular Nim way. It is much simpler than C++'s constructors that have many complex features and rules:

Custom type conversion

2024-03-13 Thread scippie
> Certainly not very "Nim like". That sentence made me look at what I was doing again and I think you are right (whether or not it was what you meant to say), so I am changing my approach a bit. Thank you all for your great answers. I have learned a lot today!

Custom type conversion

2024-03-13 Thread scippie
> You don't have to write your own to implementation, the json module provides > one which works for most object types. If you swap library to something else > you might have to re-implement to for that library if it doesn't already > exist. I know, and thanks for that information. But like I s

Custom type conversion

2024-03-13 Thread PMunch
Well if you look at the `to` procedure in the `json` module it takes a `JsonNode` and a `typedesc`. It is also very generic so your code could simply be: import json type Object = object val1: int val2: string let js = parseFile("status.

Custom type conversion

2024-03-13 Thread PMunch
Ah, no that is probably not handled. Also it might not be a great idea. Certainly not very "Nim like". Hard to tell without seeing some more code. You can make a converter anonymous by naming it `_` it seems.

Custom type conversion

2024-03-13 Thread ingo
maybe have a look at

Custom type conversion

2024-03-13 Thread scippie
That seems to work perfectly, thanks! Just to be sure, is this correct? converter toObject(node: JsonNode) : Object = result = Object( ... ) Run Is the name of the converter arbitrary? It seems to work with a completely different name too. If so, is there a reas

Custom type conversion

2024-03-13 Thread sls1005
You need a [converter](https://nim-lang.org/docs/manual.html#converters).

Custom type conversion

2024-03-13 Thread scippie
Please understand that I come from a C/C++ world (I do have experience with other languages), so I am still trying to find out how things are done. Well, the 'to' proc is, if I understand correctly, the same as my 'constructObjectfromJson' proc, only named differently. I will change the name to

Onstream vs. Pikashow: Exploring Free Streaming Apps

2024-03-13 Thread zuhab1212
Onstream.fit is a platform or website with the best and finest streaming app, which lets you watch unlimited movies without spending a penny. So, if you are interested in watching movies and web series, then don't get too late to grab this opportunity and download the onstream app's latest versi

Custom type conversion

2024-03-13 Thread PMunch
Then I'm not entirely sure what your actual concern is. You could always overload the `to` proc with your own implementation for any other format. Or you could name it something else. Another option would be to write a [converter](https://nim-lang.org/docs/manual.html#converters) if you want the

Custom type conversion

2024-03-13 Thread scippie
I understand, but in this case we are talking about Json, but next time it may be something different or even custom. I didn't make that clear in my OP, but I may step away from json at some point.

Custom type conversion

2024-03-13 Thread PMunch
It sounds like you might be looking for `to` from the `json` module: That being said you could also work with the JSON object directly, just verify it's structure with something like `jsonschema` beforehand.

https://activeketogummieschemistwarehouseaustraliacost.company.site/

2024-03-13 Thread geetabhaskar392
Best Deals At Live => Shop Now: Best Deals At Live => Shop Now: Active Keto Gummies Chemist Warehouse Australia: For many of us, losing weight is a true fight. We experiment with a wide range of methods and strategies in an attem

How Do the CBD Care Gummies Function For Easing Every Pain?

2024-03-13 Thread cannalabsinu
CBD Care Gummies are decent for treating every single day's clinical issue. It has two or three advantages for the body, for example, the Regular amalgamation of THC is dangerous for the body and may give results, for example, skin responsive characteristics, debasements, and contamination. Diff

Active Keto Gummies Trustpilot Au/Nz What Are The Benefits Of Using It?

2024-03-13 Thread Foomil
Active Keto Gummies Trustpilot Au/Nz fitness is more consistent than getting in shape. Before long, you'll be bloated and heavy, but in order to lose the extra weight you need to shed from your body, you really must tighten up. You have to spend hours at the training center and adhere to a stric