Interesting proposal for Error handling and Null through unified option Type.

2022-05-15 Thread solomonthewise
the second one is pretty much what I proposed just feels lacking a few features. I kinda feel it would need to be implemented at a language level to be powerful. thanks for sharing

Interesting proposal for Error handling and Null through unified option Type.

2022-05-15 Thread solomonthewise
Just had this thought on my mind and am curious what others think. quick note, even if this is actually a good idea it might be impossible to implement in a reasonable time frame. Both null and Error occur when we get a value we do not want and we have to choose how to handle it. Oftentimes the

How to initialize a ref seq type

2022-05-03 Thread solomonthewise
building a lisp. the code was as follows. MalType* = object case mk*: Mk of mklist: lis*: seq[MalType] of mkint: intval: int of mkstring: strval: string of mkfloat: floatval: float of mkbool: boolval: bool Run because of the r

Is Object significantly less efficient then ref object over here

2022-05-03 Thread solomonthewise
thanks so much for the detailed reply. I was mainly worried about the recursive aspects since the type has a field seq[itself] as well as it being arbitrarily long (since its a ast).

Is Object significantly less efficient then ref object over here

2022-05-03 Thread solomonthewise
that makes sense. :) thank you

Is Object significantly less efficient then ref object over here

2022-05-03 Thread solomonthewise
thanks so much. what do you mean by direct recursion?

Is Object significantly less efficient then ref object over here

2022-05-03 Thread solomonthewise
this is my current code it runs but im wondering if it would scale badly or have weird behaviors. MalType* = object case mk*: Mk of mklist: lis*: seq[MalType] of mkint: intval: int etc Run compared to this MalType* = ref object

How to initialize a ref seq type

2022-05-03 Thread solomonthewise
Thanks

How to initialize a ref seq type

2022-05-03 Thread solomonthewise
I have a type defined as follows. Lis* = ref seq[MalType] not nil Run but when I try to initialize it like this x: Lis = @[] #or x: Lis[] = @[] Run i get a error

Nim v2: what would you change?

2022-05-03 Thread solomonthewise
better sum types. default no nill but can be added explicitly(either with option or regular NIL). strict funcs default. BATTERIES INCLUDED. good libraries should become part of the std/library once support can be promised. being part of std/library feels like a guarantee that the library is mai

parseint not defined for char.

2022-03-27 Thread solomonthewise
I don't mean to sound catty when I say this but is nim not meant for beginner programmers as well? this is something I struggled with while learning nim. the solution I eventually found was to turn it in to a string using $. However this was not immediately obvious for me how to do. I also didn'

parseint not defined for char.

2022-03-27 Thread solomonthewise
is there a reason why its not provided in the std/library. It would seem just as useful as the original?

parseint not defined for char.

2022-03-27 Thread solomonthewise
this could just be a me mistake where I can't find the equivalent in the std/library for parseint on char. this code returns a error though. echo "123456".reversed.map(parseInt) while this code does what it is supposed to. echo "123456".reversed.mapIt($it).map(parseInt).

confusing behavior do to overloading of and for binary and, as well as logical and.

2022-03-27 Thread solomonthewise
top_row and (b.mask + (1 shl (7 * row))) == 0 gives a error while (top_row and (b.mask + (1 shl (7 * row == 0 gives the result I want. notice that b.mask is a int64 and so is top_row. I think I know why this occurs. since with the brackets and becomes binary and, then without the brackets it

`$` not working on custom type when imported in other modules

2022-03-27 Thread solomonthewise
I defined a type called int_b = int64 and defined a specific print format for it using $. It works within the module its defined in however when I attempt to print a int_b in another module I get this error message. I made sure to add the * so it would import. I'm likely making a stupid mistake

how to make a enum with wrapped ordinals

2022-03-25 Thread solomonthewise
thanks, I still haven't figured out generics yet so this is very helpful. I'm wondering why this isn't the standard behavior for enums though. Every single time I've created a enum I've wanted it it wrap

how to make a enum with wrapped ordinals

2022-03-25 Thread solomonthewise
I was working on a connect 4 app and I created a enum called player. with two different values. I want the ability to easy swap the value of player using inc(p) but when I do that I get a overflow error. This makes enums a lot less useful for me. Is there a way to have a enum type that wraps bac