Fused multiply-add instruction

2024-02-22 Thread awr1
there are many (recent!) x86 and ARM processors that do not support true non-rounded FMAs, e.g. the Celerons. implicitly setting `-march=mative` would also inherently makes many nim programs non-portable by design which is an assumption we really do not want to make. the libc impl does implicitl

Is it impossible to declare an _empty enum_ under quote in order to populate it later in a macro?

2024-02-19 Thread awr1
nim is not lisp, that it has a more complicated grammar beyond sexps means ultimately that there are AST substitutions you cannot do in `quote do`. this is why when building macros you should always keep `astGenRepr` close by in case you do have to get dirtier. as your concern is with readabili

TCC on ARM(el) backend problem

2024-01-21 Thread awr1
in fairness to OP it can be often vague where "official support" begins and ends in the compiler. if you don't want people using TCC as the backend then it should be deprecated, otherwise it will be just assumed as a feature, esp. without any experimental flags blocking usage

TCC on ARM(el) backend problem

2024-01-21 Thread awr1
> There I only can surrender. codegen on other compilers for atomic compare-and-swap uses the compiler intrinsic directly. TCC being so barebones as it is uses x86 inline asm in absence of compiler builtins. seems like the impl was borrowed [from here.](https://stackoverflow.com/q/833122) ARM

Custom constructors

2024-01-11 Thread awr1
> It would be nice to be able to at least disable default constructors. We have > various hooks now, so it seems it'd be a natural extension from there. > There's just some cases when a default object constructor needs to be > disabled or overridden. what about `{.requiresInit.}`?

Why is `enumerate()` a macro?

2023-12-15 Thread awr1
what even is the difference in functionality between `enumerate` and the `pairs` iterator?

Should conversion outside of a range result in a Defect

2023-11-17 Thread awr1
Use the compiler flag `--rangeChecks:on`

[help] Nim JIT + REPL with clang backend + -emit-llvm + LLVM's ORCv2

2023-09-22 Thread awr1
Interesting work! I feel getting JITs work in Nim would dovetail quite nicely with NimScript (especially in the context of embedding Nim plugins to user applications). However, [I thought NLVM also had support for ORCv2?](https://github.com/arnetheduck/nlvm/blob/master/nlvm/lljit.nim)

Allowed key types in std/tables

2023-09-02 Thread awr1
`std / tables` pulls in `std / hashes`: the reason `seq[string]` works out of the box is because that there is a [hash function for a generic `seq[T]`](https://nim-lang.org/docs/hashes.html#hash%2CopenArray%5BA%5D%2Cint%2Cint), which in return calls the `hash()` function over each of its element

More info on NimMain procedure

2023-08-27 Thread awr1
approximately, `NimMain`: * pulls in command line arguments * links to all `{.dynlib.}` procedures * if needed, starts TLS emulation * if needed, start the GC * if needed, registers all nim-side procedures and globals with the HCR (hot-code reloader) * initalizes the nim-side callstac

One language to rule them all.

2023-08-26 Thread awr1
unrelated but the time limit on being able to edit anything is kinda silly - would have preferred to be more concise.

One language to rule them all.

2023-08-26 Thread awr1
> However, a senior programming educator and a former engineer told me that > such a language is impossible due to the "Church-Turing thesis". In all honesty, this is a bad and unrelated answer (and kind of a cop-out). Nim is not trying to question conundrums of computability, Nim is questioning

[Scala background] How does a macro in Scala differs from macro in Nim?

2023-08-14 Thread awr1
I assume a reference to [this](https://forum.nim-lang.org/t/10135#66993)

How to echo distinct type

2023-08-14 Thread awr1
entirely unrelated. it's specifically for extending procedures from a base type to a distinct type

[Scala background] How does a macro in Scala differs from macro in Nim?

2023-08-14 Thread awr1
> If you have background in programming with Scala, could you please explain > how does a macro in Scala and Nim differ AND why aren't they more popular in > Scala? I suspect it may be because the language is in a "Python 2 -> 3" bifurcation moment. It has been a long time since I've personall

How to echo distinct type

2023-08-14 Thread awr1
you can borrow like so: type Foo = distinct int proc `$`(x: Foo): string {.borrow.} echo (Foo 1) Run also, instead of borrowing, you can use `distinctBase` for weird type-general nonsense: import std / typetraits type Foo = dis

Why is My Nim Code Faster when Doing This

2023-08-07 Thread awr1
one of the things that is also less fortunate about this example is that there is a latent yet untaken opportunity for DCO to turn `reverse` into a noop the way it's used in the loop.

newSeq() named inconsistently?

2023-08-04 Thread awr1
there once was a point where it was easier to have momentum on stuff like this, in spite of w/e significance it has and whatever degree of relation it has to the "bigger picture" of the language as a whole, primarily because there were fewer affected parties using the language in general. this i

Problems compiling objc code including on osx

2023-08-03 Thread awr1
* the header is unnecessary if you have the binary definitions, which is that `MTLDevice` is a `ptr object` and that `MTLCreateSystemDefaultDevice()` is of calling convention `cdecl` * you need to also link in `-framework Metal` and `-lobjc`. if you want to use the header you need to pass the fr

newSeq() named inconsistently?

2023-08-03 Thread awr1
i am not really sure that i am a fan of adding `init` and `new` as it would give the false impression of how constructing objects works in Nim. an alternative convention: `init` and `new` in this case do not refer to copying semantics but whether or not the object is heap-backed.

Top-level generic variable

2023-08-02 Thread awr1
Reminds me of the [type union operator from Pike.](https://pike.lysator.liu.se/docs/man/chapter_3.html#3.3.3)

Nim version 2.0.0 is here

2023-08-01 Thread awr1
Very glad to do a `choosenim update stable` today!

Does Nim has the same features that D has when interfacing to Objective-C?

2023-06-23 Thread awr1
nim can technically "compile to Obj-C" and produce loose method calls through `{.importObjc.}`, [found here in the docs](https://nim-lang.org/0.20.0/manual.html#implementation-specific-pragmas-importobjc-pragma). however this interface is pretty much one-way: e.g. you can't subclass in pure nim

MoveWindow()

2023-06-19 Thread awr1
[here you go.](https://developer.apple.com/documentation/appkit/nswindow/1419690-setframeorigin?language=objc) you may prefer using a cross-platform windowing library instead, e.g. [SDL2](https://github.com/nim-lang/sdl2) or [windy](https://github.com/treeform/windy)

Malebolgia & Pixy problem: expression has no address

2023-06-17 Thread awr1
make sure there are no captures in the call - in your case `image` is implicitly captured. instead you would want to pass it as a `var Image`. also the return type should be void as you are not actually returning an `Image` from that procedure.

Malebolgia & Pixy problem: expression has no address

2023-06-17 Thread awr1
also from a cursory glance this may fail because `proc` is probably being considered as a typeclass here instead of as a concrete procedure type in the context of `assign()`

Malebolgia & Pixy problem: expression has no address

2023-06-17 Thread awr1
firstly, you probably want `for j in 0..https://github.com/Araq/malebolgia/blob/master/src/malebolgia.nim#L168). this works for `seq[T]` elements because `[]` returns a `var T` [in the stdlib](https://github.com/nim-lang/Nim/blob/version-1-6/lib/system.nim#L2644) whereas pixie defines a `[]=` (a

Why `unsafe_addr` had to be used in StringSlice?

2023-06-15 Thread awr1
> Nim won't allow to use addr and suggest to use unsafe_addr instead, why? `unsafeAddr` is on its way out for 2.0 iirc but, moving beyond reorienting around arrays: parameters are constant in Nim (unless you use something like `var`) through which whether a copy or an implicit ref is passed beco

Heap allocated variables that behave like stack variables?

2023-06-09 Thread awr1
why not just use `newSeq[float32](largeNumber)`? just remember not to push or pop anything (which won't happen if the array is piped into a `let` or `const` anyway). it's not entirely 100% clean, like you get an unused negible `capacity` value, etc. but for all intents and purposes it is probabl

Nim library interoperability with other GC languages (NodeJs, Golang)

2023-06-06 Thread awr1
when it comes to intermingling managed code in which multiple memory management schemes have no actual knowledge of each other, you need to use the language's built-in utilities to preclude object destruction. C#, for instance, has [`unsafe` contexts](https://learn.microsoft.com/en-us/dotnet/cs

DLL Terms

2023-06-06 Thread awr1
imo Win32/NT is for the most part more sensibly designed than UNIX (and even then, MacOS tries to hide its UNIX heritage very frequently, aside from the most basic OS bookkeeping substrata) in any case it matters little because (being a cross-platform language, as most languages tend to be) Nim

DLL Terms

2023-06-05 Thread awr1
I agree (Nim has the habit of being a little Windows-centric) - perhaps [submit a PR](https://github.com/nim-lang/Nim/blob/devel/doc/nimc.md#dll-generation)?

NIM code compile to executable does not run on other systems.

2023-05-25 Thread awr1
Try compiling with `--app:gui`. If you have DLL errors it will show up as a dialog box instead of popping in an command line which might vanish very fast if you launch from explorer. I took a look at your deps and I would concur with @Yardanico, however, looking at the deps for `dimscord`, I wo

Platonic: core math concepts

2023-05-25 Thread awr1
FWIW I've been using static ranged dimensions for a while in my own (short, 2-4 dimensions) vectors + matrixes plus distinct types for unit vectors, colors, etc. and I really find it quite easy to deal with. (Though my context is graphics/game engineering, not ML/numeric processing, so my commen

Type binding generic alias with extra parameter

2023-05-01 Thread awr1
OP, have you tried this? This seems to work. type Foo[T] = object x:T Bar[T,R] = Foo[T] Baz = Bar[int,float] proc qux(x: Bar) = discard var b:Baz b.qux() Run

Small experiment with compiling the Nim compiler with PGO

2023-04-27 Thread awr1
@Yadarnico have you tried MSVC's PGO at all w/ the Nim compiler (or are you not on Windows?)

Semcheck a NimNode tree?

2023-04-27 Thread awr1
> What are the use cases? There are four main things I can think of: * Parsing trees with mixed semantically-valid and DSL code (e.g. the prior example) * Including generated code from a cache that must be programmatically retrieved (such as Nimterop/Futhark etc.) with better semantic analy

Semcheck a NimNode tree?

2023-04-26 Thread awr1
To be more specific with what I mean: the semcheck pass performed with `typed` only works with code blocks produced directly from the source. There is no `proc typify(node: NimNode): NimNode`. If an AST is produced either from the compile time VM or (probably more usefully) if there are specific

Checking whether we are in .compileTime

2023-04-26 Thread awr1
Have you tried using the compiletime FFI too?

Semcheck a NimNode tree?

2023-04-26 Thread awr1
In Nim, macros and templates have the ability to be designate their params as being `typed` or `untyped` which enables a user to optionally pass their input to the semantic stage (and produce symbol-bounded, constant-folded, etc. AST trees as a result), or avoid the semcheck if a less “Standard

Object Arrays

2023-04-08 Thread awr1
if for some reason you do need this array at compile time, there is really no necessity for using generic params, just use `const`.

Nim v2: what would you change?

2022-06-14 Thread awr1
TBH I'd be in favor of forking this off and starting a new thread (or GH issue) focusing on stdlib issues versus language/compiler-level/package managment issues; especially RE: breaking some of the existing libraries off into `fusion`.

Nim v2: what would you change?

2022-05-27 Thread awr1
* more willingness to breaking changes in the stdlib, for sure, as others have said, and hunt down inconsistencies/reduce the number of "alternate approaches" that exist. consider moving certain libraries over to fusion and take fusion more seriously. for instance, just off the top of my head:

import from url

2022-03-03 Thread awr1
This also makes it easier for Nimble to comprehend a package's dependencies. That being said, Nim already supports some interesting ways of establishing dependencies through Nim code itself (albeit from a different angle - Nimterop comes to mind). Personally, I don't see much of an advantage to

Factorial computation in Nim

2022-03-01 Thread awr1
> Do you use other things for benchmarking ? Try [cpuTime()](https://nim-lang.org/docs/times.html#cpuTime) or [monotimes](https://nim-lang.org/docs/monotimes.html).

Why windows.h file is always included into compilation on Windows?

2021-12-24 Thread awr1
Actually, silly me: you can define `wWinMain()` without needing `windows.h` like this: int __stdcall wWinMain(void* w, void* x, void* y, int z) {} Run

Why windows.h file is always included into compilation on Windows?

2021-12-24 Thread awr1
On the point of removing `windows.h` from the Nim compiler/standard lib: > GetLastError is declared in lib/system/excpt.nim and > lib/system/threadlocalstorage.nim. These APIs should be moved to winlean > module? I would avoid doing this. `winlean` is still pretty large (considering it is a tr

Pythons None in Nim

2021-12-20 Thread awr1
`int.low` is an inferior method, as it becomes a magic value unlike the option which forces you to check. However options as they currently are strike me as limited in the optimization department because internally an `Option[int]` will be represented as a `(has: bool; value: int)` in memory whe

Nim with curly brace and tab

2021-12-18 Thread awr1
If you feel awkward coming to Nim after getting so used to braced languages, believe me, after a while you will get used to it and maybe end up preferring it in the end. Discussions about syntax can be important (to provide an extremely arbitrary example: Nim doesn't "cheapen" the syntax at the

Why windows.h file is always included into compilation on Windows?

2021-12-14 Thread awr1
We already generally avoid `{.include.}` for Win32 API stuff, as `winlean` mirrors the API (basically a translation of `windows.h` w/ `WIN32_LEAN_AND_MEAN` def'd) in general but pulls the necessary functions in through `{.dynlib.}` instead of through the C header. There are a few places where w

Advent of Nim 2020 megathread

2020-12-11 Thread awr1
My repo can be found at <https://github.com/awr1/aoc>