how to borrow iterator `items` for distinct type?

2024-04-29 Thread shirleyquirk
for the compiler crash iterators cant be borrowed, you'll need to manually iterator items(a: A): uint8 = for i in cast[array[4,uint8]](a): yield i Run

Oversight or intentional?

2024-03-22 Thread shirleyquirk
to get gcc to tail-call any recursive proc you need to write it in an awkward way, making sure the last statement is the recursive call. but doing so with a closure or a proc results in tail-call optimization, at least for this toy example: giant YMMV applies,

Oversight or intentional?

2024-03-22 Thread shirleyquirk
you can write recursive, self-capturing lambdas if you name them first import sugar var fib:int->int fib = (x:int) => (if x < 2 : x else: fib(x-1) + fib(x-2)) echo block: collect: for i in 0..10: fib(i) Run

Beginner question: mixing types in a sequence

2024-02-23 Thread shirleyquirk
i'd recommend you read through the nim tutorial and manual, the sections on variants in the [tutorial](https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants) and [manual](https://nim-lang.org/docs/manual.html#types-object-variants) in particular. type Nod

Buildroot host-nim package?

2024-02-22 Thread shirleyquirk
my buildroot is pretty rudimentary but i came up with: # # Nim # NIM_VERSION_MAJOR = 2.0 NIM_VERS

Buildroot host-nim package?

2024-02-21 Thread shirleyquirk
At $dayjob we use buildroot, so for me to introduce any nim would require at least a buildroot host package. That is, a package that would compile nim on the build machine (amd64/linux) as part of the toolchain. I can write one, but i thought i'd ask around first to see if anyone else has done t

cannot open: /dev/stderr

2023-12-13 Thread shirleyquirk
> I wonder why it fails writing to stderr. its even more of a head scratcher how it can write the exception to stderr after it couldnt write to stderr

Nim program crashes when using recursivity and openarray

2023-12-13 Thread shirleyquirk
using `[..]` creates a seq[char] from your openArray, so your function uses O(n^2) memory and is possibly being killed by the os. instead of using `..` use `recursiveExplorer(toOpenArray(s,0,s.len-2))` and you wont produce a copy

undeclared identifier error when using string format in template

2023-12-12 Thread shirleyquirk
this is discussed in the workaround is import std/[strformat,strutils] import std/[enumutils,sugar] template printEnumMembers(E: typedesc[enum]) = for i in E.items: # it works #echo "[$1]: $2 ->

undeclared identifier error when using string format in template

2023-12-12 Thread shirleyquirk
annoying that `capture` doesn't work for this situation as well.

Is it possible to encode constraints directly into a type, and enforce them at runtime?

2023-12-09 Thread shirleyquirk
[requiresInit](https://nim-lang.org/docs/manual.html#statements-and-expressions-var-statement) is kinda like the deleted default constructor from c++, but cleverer. it prevents the situation where you can var h: Hand echo h #oh no, it's an empty string that invalidates our preco

Is it possible to encode constraints directly into a type, and enforce them at runtime?

2023-12-07 Thread shirleyquirk
lol. fair. me too. i agree the Hand(string) constructor for distinct types is an attractive nuisance. we can get rid of that. but you'll have to have the self-control not to use `cast`. what you can do is, put your Hand type, and its constructor in a separate module, and only export the type a

Is it possible to encode constraints directly into a type, and enforce them at runtime?

2023-12-07 Thread shirleyquirk
if you've got adversarial users, you need to validate all inputs at the api boundary.

Is it possible to encode constraints directly into a type, and enforce them at runtime?

2023-12-07 Thread shirleyquirk
something has to parse it. This is AdventOfParsing after all. if you know all the input strings at compile time one way could be: import macros const validCard: set[char] = {'A','J','Q','K','0'..'9'} type Hand = distinct string macro validate(s: static string)

meaning of benign and rtl pragmas

2023-11-30 Thread shirleyquirk
i would love to see a blog post about your journey with ropes: they seemed to hold promise and held sway in the core for a long time. i dimly remember that some benchmark changed your mind about them, would you think it worthwhile to write up that experience?

Issue with calling a routine defined in a concept

2023-10-23 Thread shirleyquirk
That's a bug yep. Please report it on the github bug tracker, and thank you in advance for your service. No, rfc 168 won't make it compile, thats orthogonal.

How to echo from a proc correctly?

2023-10-18 Thread shirleyquirk
A template is sufficient: import std/macros template playAndWriteLN(audioFile: string; myStr: varargs[typed]) = PlaySound(`audioFile`, 0, SND_NOSTOP) echo.unpackVarargs(myStr) Run

concepts and openArray

2023-09-21 Thread shirleyquirk
since slicing and concatenation change the array type you can split up your concepts: import std/enumerate type SliceableStream[T] {.explain.} = concept s s[Natural..Natural] is BaseStream[T] BaseStream[T] {.explain.} = concept s s[Natural] is T

Using Result library

2023-09-21 Thread shirleyquirk
i've been working with a Result clone written on top of std::expected, and, while i miss pretty much everything else about nim-result, ive grown to enjoy being able to return a bare T from a function returning Result[T,E] #include #include using err_t = std::string; te

Just installed nim 2.0 and vscodium can't run a nim program

2023-09-19 Thread shirleyquirk
This will be that package management changed from 2.0 pacman has worked around this by adding a symlink Does pacman work on manjaro? Surely pamac is a wrapper

What is the meaning of () after an enumeration symbol?

2023-06-02 Thread shirleyquirk
now where's the `proc csAuto()` that returns a `GridDir`?

Is there a way to tell the compiler to include/export unused functions

2023-05-17 Thread shirleyquirk
Something I do to convince the compiler to export (non generic) procs is, as you mentioned, add {.dynlib.} Maybe you don't know, you can use the `{.push.}` pragma to apply a pragma to all following procedures. So {.push,dynlib.} proc foo() proc bar() ... #optional

std/paths and $ proc

2023-05-17 Thread shirleyquirk
A `Path` is a `distinct string` so you can `echo my path.string` but I get your point

A memory management idea

2023-05-17 Thread shirleyquirk
for arm64 and x86_64 you can smuggle that flag in the top 16 bits. import std/bitops const ptrmask = 1'uint shl 63 proc `[]`[T](dest:Ptr[T]): var T = cast[ptr T](cast[uint](dest.p).clearMasked(ptrmask)) proc initPtr[T]():Ptr[T] = cast[ptr T](cast[uint](all

feasible lib(s) to do FFT on image with minimal dependencies?

2023-05-14 Thread shirleyquirk
> all you need is a fast to-JPEG converter Yes, if the DCT is an acceptable alternative to the FFT, then check out [pixie](https://github.com/treeform/pixie)

Is there a way to tell the compiler to include/export unused functions

2023-05-13 Thread shirleyquirk
What does it mean to export a generic proc? Do you instantiate it infinite times, once for every possible type?

Why `!=` is template and not a func?

2023-05-12 Thread shirleyquirk
> any problem domain that rely on ... NaN NaN gates and Flip FLOPS by tom7, [paper](http://tom7.org/nand/nand.pdf) [video](https://www.youtube.com/watch?v=5TFDG-y-EHs) abuses ieee754 compliance to its limits there's no equality comparisons involved, but many of the operations rely on ieee754-c

Can't import compiler/* anymore

2023-05-11 Thread shirleyquirk
What would the best way forward be, then. > The 'compiler' directory should be placed in /usr/lib/nim ?.

Upcoming `Result` review - comments and thoughts welcome!

2023-05-09 Thread shirleyquirk
This doesn't work: import std/strformat import results proc foo():Result[void,cstring] = let res = -1 err(&"failed {r}") Run because Result[T,cstring] is special-cased to 'avoid dangling cstring pointers' is there a simple test case that you can sha

bug (?) with nested templates in generic proc

2023-05-07 Thread shirleyquirk
Wow. Amazing. we need a wiki full of these tricks, or something more searchable than this forum. I'd upvote both q and a on stackoverflow if someone wants some free karma

How to cast or pass a {.closure.} as a callback to a C API with userdata pointer?

2023-05-06 Thread shirleyquirk
You can access the environment with [rawEnv](https://nim-lang.org/docs/system.html#rawEnv%2CT) and the function pointer with [rawProc](https://nim-lang.org/docs/system.html#rawProc%2CT)

2 blocks 1 indentation

2023-05-04 Thread shirleyquirk
short answer no. This is the parsing tradeoff between curlies and indentation syntax. There are more functional syntaxes available, that you might like, e.g. import zero_functional for i in 0..10: if i mod 2==0: echo i 0..10 --> filter(it mod 2 == 0) --> f

Arch package not up-to-date with 1.16.12

2023-05-04 Thread shirleyquirk
All you can do is mark it out of date on [the arch site](https://archlinux.org/packages/community/x86_64/nim/) the official package is not maintained by a nim community member, but by an arch community legend with a lot on their plate. IiRC there are some packaging differences coming up so I ex

Mojo Language: Similarities/Differences with Nim, Potential Lessons for Adoption

2023-05-04 Thread shirleyquirk
in inim you can edit functions, you drop down into editor mode and you can see the whole file. I don't use this because it's not useful at all. Neither is the python repl. Redefining multiline functions after a typo in the python repl is annoying as all get out. The Jupyter notebook model, howe

Type binding generic alias with extra parameter

2023-04-30 Thread shirleyquirk
ok, it does work () on 1.6.12: type Foo[T]{.pure.} = object {.inheritable.} x:T Bar[T,R] = object of Foo[T] Run on devel type Foo[T]{.pure,inheritable.} = object x:T Bar[

Type binding generic alias with extra parameter

2023-04-30 Thread shirleyquirk
The solution I'm using right now is to add an unused counter static int parameter to Bar, and a CacheCounter that's incremented in `makeBar` it makes 2 `makeBar(int,float)`s distinct/dispatchable, but of course they are both `Bar` so all of Bar's api works This was straightforward only because

Can I download Nim on my iOS or Android device?

2023-04-29 Thread shirleyquirk
Replit is stuck on version 1.4, but it's otherwise good.

Type binding generic alias with extra parameter

2023-04-29 Thread shirleyquirk
i didn't know about `{.borrow:'.'.}` thanks for that. unfortunately it doesn't work through an alias: type Bar[T,R]{.borrow:`.`.} = distinct Foo[T] Baz = Bar[int,float] ## Error: only a distinct type can borrow '.' Run tbh, this is why i dont muck around w

Type binding generic alias with extra parameter

2023-04-28 Thread shirleyquirk
type Foo[T] = object x:T Bar[T,R] = Foo[T] Baz = Bar[int,float] proc qux[T,R](x: Bar[T,R]) = discard var b:Baz b.qux() Run fails to compile with "cannot instantiate 'R'" a workaround is `Bar[T,R] = distinct Foo[T]`, which is awkwa

Semcheck a NimNode tree?

2023-04-27 Thread shirleyquirk
I just submitted a stackoverflow question on this topic, I edited @PMunch's answer with how I ended up implementing it, but my edit wasn't accepted. It was essentially @choltreppe

Hex to bytes - How to convert

2023-04-21 Thread shirleyquirk
the [manual](https://nim-lang.org/docs/strutils.html#toHex%2Cstring) provides this helpful link:| > See also: > >> [parseHexStr](https://nim-lang.org/docs/strutils.html#parseHexStr,string) >> func for the reverse operation

How to inverse set?

2023-04-18 Thread shirleyquirk
> P.S. The char set is stored as 256 bit vector right? Yes, `sizeof({'a'..'z'}) == 32` But `sizeof(set['a'..'z']) == 4`

How to make os (e.g. ubuntu) interpret nimscript shebang

2023-04-18 Thread shirleyquirk
> two or more arguments in shebang might not be accepted by the system or > shell, Yes, that's what the `-S` is for, it lets you pass multiple arguments

How to make os (e.g. ubuntu) interpret nimscript shebang

2023-04-16 Thread shirleyquirk
Works for me. You forgot the 'e'

What GPT-4 knows and thinks about Nim

2023-04-15 Thread shirleyquirk
Beautiful website by Mr Salewski. > It’s worth noting that 90% of the page content is currently generated by > GPT-4, and we haven’t checked it for accuracy yet. Perhaps we should. > Alternatively, we could ask GPT to proofread and correct the content itself – > maybe that will be possible soon

Upcoming `Result` review - comments and thoughts welcome!

2023-04-13 Thread shirleyquirk
One more performance/ergonomics thing: I'm used to, and love, the implicit `result` variable, but trying to work entirely with Result gets in the way. How do folk get back some of that without proc initFoo():Result[Foo] = var res: Foo ## lots of individual field inits

Scan syntax tree for procedure calls

2023-04-12 Thread shirleyquirk
Tag Tracking has been in the manual since at least 1.0, the experimental bits are the StrictEffects, 'effectsOf' and 'forbids' stuff which build on top of machinery that has been a part of Nim since the beginning. So, when used as I've done in my toy example, it's not experimental. In particula

Speeding up compile times

2023-04-12 Thread shirleyquirk
You could also look at using a caching c compiler like zapcc

Scan syntax tree for procedure calls

2023-04-11 Thread shirleyquirk
[Tag tracking](https://nim-lang.org/docs/manual.html#effect-system-tag-tracking) isn't experimental, and `effecttraits` is since 1.4.

Scan syntax tree for procedure calls

2023-04-11 Thread shirleyquirk
Tracking calls inside the call chain seems like exactly what the effects system is for: import std/[macros,effecttraits] type FooTag = object macro callsFoo(p:proc):untyped = for t in getTagsList(p): if t.eqIdent("FooTag"): return newLit(tru

Upcoming `Result` review - comments and thoughts welcome!

2023-04-06 Thread shirleyquirk
I find myself overloading `valueOr` to work with `Result[void,E]` what's the reason for leaving that out? How much work would it be to avoid copies when possible? It feels very edgecasey, pattern matching whether `expr` in `?expr` is an nnkCall etc

Nim 1.6 vs 2 (1.9) Working with channels

2023-04-03 Thread shirleyquirk
I cant use `threading/channels` in production when tsan complains about them. Its a struggle already to advocate for using a language at work that's not c/c++, If I build this project on top of a buggy stdlib it'll be the end of Nim at my workplace. ( my job won't be more secure either lol) May

/usr/lib/nim/lib/system.nim

2023-03-19 Thread shirleyquirk
No apologies necessary, I’m very happy with this change. koch tools doesn’t make dochack for me A quick search through koch.nim and I can’t find dochack anywhere. Instead, ‘getDocHackJs’ in compiler/nimpaths.nim seems to compile it if it doesn’t exist

Do you miss these compact syntaxes?

2023-03-18 Thread shirleyquirk
> Postfix ... abomination I couldn't agree more. Welche Monster ihre Verben am Ende von Ausdrücken behalten würden?

/usr/lib/nim/lib/system.nim

2023-03-18 Thread shirleyquirk
that's great work. and we should maybe talk about this in the aur comments instead of here, but some of the following could be relevant for other packagers. problems with nim-git: 'docs/*' are put into /usr/share/nim, instead 'docs/nimdoc.c{l,s}s' need to be in /usr/lib/nim/doc 'nim-gdb'

/usr/lib/nim/lib/system.nim

2023-03-17 Thread shirleyquirk
This is an issue with `nim-git`, i added a [comment](https://aur.archlinux.org/pkgbase/nim-git#comment-906500) the [packaging instructions](https://nim-lang.github.io/Nim/packaging.html) were changed in [this commit](https://github.com/nim-lang/Nim/commit/6c15958a835b645f3acdc3d1d012b10d0df4345

Trying To Slice the Characters Where Needed.

2023-03-15 Thread shirleyquirk
I could only find the documentation for [slicing a seq](https://nim-lang.org/docs/system.html#system-module-seqs), but it works the same way: let s = "1234567890" echo s[0..4] echo s[5..^1] Run

Export C library components when using `--app:lib`

2023-03-15 Thread shirleyquirk
maybe this is too naive a toy example, but it works: `clib.c` int sum(int a,int b){return a+b;} Run `nimlib.nim` {.compile:"clib.c".} #proc sum(a,b:int32):int32{.importc.} ## as @auxym says; if it's not static, it's exported ## even i

Difference between generics and templates

2023-03-12 Thread shirleyquirk
var a = (proc(s: string))(doThing) Run Always wanted to know how to do this, thanks @eb

Can Nim do Type States?

2023-03-10 Thread shirleyquirk
I think Zig would be more aligned with that ethos of no-surprises, no code generation. Nim is never going to be that. I came to Nim for embedded because my philosophy is: having code that's written at the right level of abstraction is how to write comprehensible code, and clear, comprehensible,

Can Nim do Type States?

2023-03-10 Thread shirleyquirk
@dwhall > My line of work prohibits metaprogramming What does this mean? I work in embedded, too, not like, misra-level or anything but I've never come across any restrictions limiting the level of abstraction. Wouldn't mplab/harmony/all those code configurators from microchip count as meta

{.nodecl} VS {.importc, nodecl} and return VS result

2023-03-09 Thread shirleyquirk
No, of course destructor, yes. > sorry for conflating my experiment with this post's question, which was, how > do you `nodecl` a variable. My experiment was exploring whether theres a way to supply a `finally` block when unwrapping a `Result`

{.nodecl} VS {.importc, nodecl} and return VS result

2023-03-09 Thread shirleyquirk
The hack I've found to do this: proc foo() = proc cleanup(p:pointer){.used.} = echo "cleanup" var x {.codeGenDecl:"",nodecl,noinit.}: seq[int] {.emit:[typeof(x)," ",x," __attribute__((cleanup(",cleanup,"))) =",@[5],";"].} echo x foo()

iterators composition

2023-03-05 Thread shirleyquirk
zero_functional all the way

ffi: how to pass a value to c?

2023-02-24 Thread shirleyquirk
I'm not wrapping C code, I'm replacing it, but keeping the api

ffi: how to pass a value to c?

2023-02-23 Thread shirleyquirk
I am definitely overthinking things. And this should be a stackoverflow post instead. I'll do that later. However. My first try was nim altera_jinit(js: var TapDriver) = js = TapDriver(...) Run and that segfaulted with orc somewhere in `=sink`. Maybe that's a b

ffi: how to pass a value to c?

2023-02-22 Thread shirleyquirk
I thought I understood this, but clearly I don't. First, too much context: `===` I'm porting parts of a C project to nim. altera-gpio.c --> usb_blaster.nim #replacing the gpio bitbang jtag driver with a libusb-based usb_blaster driver alt

Heap fragmentation, embedded systems

2023-02-20 Thread shirleyquirk
I can't speak to Nim's implementation, but the GC is based on [TLSF](https://www.gii.upv.es/tlsf/files/ecrts04_tlsf.pdf) from that paper:

Leaving out type names during compilation

2023-02-18 Thread shirleyquirk
* Don't write malware in Nim. * it's called stripping, there's a utility called `strip` for it * don't write malware in Nim

command line parametr with whitespace

2023-02-04 Thread shirleyquirk
There is a bug in `parseCmdLine` when not on windows. [this line](https://github.com/nim-lang/Nim/blob/e0328e28ee6b3fbfea812ffc2ce435ff76ccbc5a/lib/pure/os.nim#L2830) should probably be: while i < c.len and c[i] > ' ' and not (c[i] in

RosettaBoy - Gameboy emulator rosetta stone

2023-02-03 Thread shirleyquirk
> `var ref` can affect perf Is that true? If so frankly that's a legit criticism

Why Nim does not support comparison between different types?

2023-01-27 Thread shirleyquirk
char a = 0x80; char b = a << 1; printf("%s equal\n",b == a << 1 ? "" : "not"); Run What will that print? integer promotion is evil.

Unique ID's for types?

2023-01-22 Thread shirleyquirk
This is how yglukhov does it in `variant`: proc mangledName(t: NimNode): string = mangledNameAux(getTypeImpl(t)[1]) macro getMangledName(t: typed): string = result = newLit(mangledName(t)) type TypeId* = Hash macro getTypeId*(t: typed): TypeId

`std/xmltree` issue with extra spaces being added

2023-01-21 Thread shirleyquirk
import std/xmltree let x = newXmlTree("foo",[ newXmlTree("bar",[ newText("Hola"), newXmlTree("qux",[ newXmlTree("plugh",[]) ]) ]) ]) echo x Run Hola Run

Trying to make a lexer, stops if it hits an operator.

2023-01-16 Thread shirleyquirk
it's because `abst` (please begin types with a capital letter btw) is a ref object, and you're dereferencing it when it is still nil. you need to var ast = new abst Run

How do I fix this?

2023-01-15 Thread shirleyquirk
you could file an issue on @elcritch's github, but i'm pretty sure this never worked properly. to start with, it truncates the names of each node incorrectly, so you'll need to `s/substr(3)/substr(2)/` This is an instance of the same issue i liked before; a converter is defined that converts t

How do I fix this?

2023-01-15 Thread shirleyquirk
There's something in the code that _[you](https://forum.nim-lang.org/postActivity.xml#you) wrote, probably something that calls astGenRepr from macros2, that triggers the bug. What's in `gold.nim`?

How do I fix this?

2023-01-15 Thread shirleyquirk
The best thing would be a minimal example that, when compiled, gives the same error. That means, enough code for someone else to be able to compile on their machine and get the same error, but as short as possible.

How do I fix this?

2023-01-14 Thread shirleyquirk
If you share some code we can help more.

How do I fix this?

2023-01-14 Thread shirleyquirk
Are you using converters inside a case expression?

Trying to make a lexer, stops if it hits an operator.

2023-01-08 Thread shirleyquirk
i tend to do something along these lines: import std/[strutils,parseutils] type TokKind = enum def, id, str, num, kw, uk, op Token = object label: TokKind value: string const keywords = ["let", "const", "var",

Trying to make a lexer, stops if it hits an operator.

2023-01-07 Thread shirleyquirk
Oh that's so funny. When your code had all the whitespace removed, I did my best guess to reformat it, and there was one ambiguity. I had added an extra tab to the else in the `of uk` block, and it worked for me, except for the bug where it requires the input text end with whitespace

Trying to make a lexer, stops if it hits an operator.

2023-01-07 Thread shirleyquirk
You can add code blocks with triple backticks, and check that the formatting worked with the 'preview'

Two type matches, both wrong: how to do it right?

2023-01-05 Thread shirleyquirk
I would declare Square as `distinct` that's enough to get it to compile, but you could declare BitBoard distinct as well, it might save you from some silly bugs in the future. type Square* = distinct range[0..63] proc square*(file, rank: int):Square = (rank*8+file).Square pr

Regex error - "Error: missing closing ' for character literal"

2023-01-05 Thread shirleyquirk
Thanks that makes perfect sense

Regex error - "Error: missing closing ' for character literal"

2023-01-05 Thread shirleyquirk
Where did this design for character escaping via doubling come from? It violates the principle of least surprise, what benefit does it provide?

Assigning array to itself with different order

2023-01-01 Thread shirleyquirk
https://github.com/nim-lang/Nim/issues/17444

Type mistmatch for `int` and `sink T`

2022-12-29 Thread shirleyquirk
You are trying to insert an `int` into a seq of `byte`

Roadmap 2023

2022-12-29 Thread shirleyquirk
Brilliant! IC plus useable nimsuggest would be such a huge step forward. I applaud removing async and spawn from the stdlib, that's a bold move for a 'batteries-included' language but it's a credit to the language that such a thing is possible, and to the ecosystem that we have several robust an

Question about taskpools

2022-12-28 Thread shirleyquirk
you can ignore those hints, they are for the developer of `taskpools` and dont affect the functioning of the code. you can shut them up with `--hint:XCannotRaiseY:off`

nim 2.0 RC1 taskpools error

2022-12-28 Thread shirleyquirk
you need to add `{.gcsafe.}` to `fib2` like this: proc fib2(n:int):int{.gcsafe.} = Run

Parallel Fibonacci

2022-12-28 Thread shirleyquirk
all of the difference is in the speed of the recursive `fib` and how well the c compiler can optimize that.gcc| goto| setjmp ---|---|--- orc| 6s | 3.7s refc| 6s | 1.6s | clang| orc| 21s| 15s refc| 21s| 15s goto exceptions correlate with slow for this kind of code, but that differ

Parallel Fibonacci

2022-12-28 Thread shirleyquirk
import os,strutils proc fib(n:int):int = if n < 2: n else: fib(n-1) + fib(n-2) when defined(asyncthreadpool): const threadtype = "asyncthreadpool" import asyncthreadpool,asyncdispatch let t = newThreadPool() template mySpawn(x:untyped):u

Create a ref to a C allocated object to manage its memory

2022-12-27 Thread shirleyquirk
Kind of! you can convert it to an `openArray` and use it in most places

Is there a traditional rounding function?

2022-12-27 Thread shirleyquirk
> i don't see that any particular rounding style is inherently any more correct > than any other (and there are what, 6 different ways?*) but the way that `formatBiggestFloat` (and therefore strformat) works is to use `sprintf`, which, yes, uses round to even. [*] there's 8 specified for IEEE D

Strange error: single character string constants

2022-12-26 Thread shirleyquirk
> I have a simple VBA macro that does some search and replaces which gets > VBA/twinBasic code to 90% nim syntax. Nim 3.0 just dropped

question about memory management

2022-12-24 Thread shirleyquirk
> StefanSalewski/gintro is licensed under the > > **MIT License** A short and simple permissive license with conditions only > requiring preservation of copyright and license notices. Licensed works, > modifications, and larger works may be distributed under different terms and > without source

Create a ref to a C allocated object to manage its memory

2022-12-21 Thread shirleyquirk
> Is there any way to just use the C allocated objects as the referenced ones? Memory allocated by C needs to be freed by the C allocator. Memory allocated by the Nim alligator must be freed by the Nim alligator. You cannot cast a raw pointer to a Nim ref, the Nim allocator puts its housekeepin

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-21 Thread shirleyquirk
Too long already but I reread your post and realized I got a bit lost in the weeds. What I believe you were actually asking for was a way to provide an API to get out these compile time values. The actual answer is, they don't belong to the variable, they belong to the type. They are like stat

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-21 Thread shirleyquirk
Your exploration is really good, and there are in fact some things you can reason about. I don't want you to walk away thinking that the compiler is just completely fickle. Your `alt13` is actually a good illustration of it making sense. Even though I've seen confusion on the issue tracker as t

  1   2   3   4   5   6   7   >