Dear Araq, how do I create a programming language?

2024-04-18 Thread spip
Building upon Araq's answer about Nicklaus Wirth book, you can start playing with [Nim0](https://gitlab.com/pmetras/nim0) that implements a toy _Nim-compatible_ language in Nim, with references to Wirth's text. You can even practice adding some missing features...

Any known means of sorting UTF8 strings?

2023-04-27 Thread spip
Sorting code points is locale-dependant. Sorting in French is different from sorting in Spanish or German. The Unicode group has detailed the collation algorithm that uses the Unicode property files. If you want a general solution, ICU (or its variants) is the fastest path.

Can Nim be made more "purely functional""...

2022-02-17 Thread spip
> Build a new language that uses Nim as a back end, using the functional code > from a language such as Elm to emit Nim code that would be converted to c/C++ > by Nim. As macros are part of Nim language definition, so is Nim AST definition. If it were possible to plug into Nim compiler to provi

NimForum 2.2.0 - Fixes a big CVE!

2022-01-31 Thread spip
Yes, it worked with Safari on iPad 2. I found that I can access it with Chrome. It is probably related to a Javascript library as there are less and less sites that are accessible from this tablet model.

NimForum 2.2.0 - Fixes a big CVE!

2022-01-30 Thread spip
And it can't be read with old iPad now. I have to find a computer with a modern browser...

Nim Community Survey 2021

2022-01-14 Thread spip
I've frequently seen a split between North American and European developers based on language syntax preference. North Americans favour brace blocks `{ ... }` _à la C_ while European rather use Algol-originating `begin ... end` blocks or indented syntax like Python. Look at the origin of languag

Integration with C for statistics and data processing?

2021-09-22 Thread spip
Or have a look at [https://github.com/nim-lang/Nim/wiki/Curated-Packages#science](https://forum.nim-lang.org/postActivity.xml#httpscolonslashslashgithubdotcomslashnimminuslangslashnimslashwikislashcuratedminuspackages-science)

Nim for Beginners #26 Reference Objects

2021-09-20 Thread spip
> The other point is, that you said that for references we do not need the var > keyword when passing data to procs -- we can modify the fields of object > passed as references always. Well, beginners may be confused: Is the most > significant advantage of references that we don't have to type t

Int/Floating Point Cast Result

2021-05-17 Thread spip
Have you read [the blog post on Trace of Radiance](https://nim-lang.org/blog/2020/06/30/ray-tracing-in-nim.html)?

How to make Nim more popular

2021-05-12 Thread spip
I find strange that there is no German page for [Nim in Wikipedia](https://en.wikipedia.org/wiki/Nim_\(programming_language\)).

Tabulation symbols not allowed

2021-05-10 Thread spip
A simple way to check if your view is worth it, you can try to implement mixing tabs and spaces in [toy compiler Nim0](https://pmetras.gitlab.io/nim0/). You only have to look at the 5 [ossIndentXXX](https://gitlab.com/pmetras/nim0/-/blob/master/src/OSS.nim#L186) procedures that manage syntax in

[ANN] Nim0, a playground to learn compiler internals

2021-04-27 Thread spip
I don't care moving Nim0 repository from GitLab to GitHub if it can help collaboration on that project. I can even share it with another maintainer if someone is interested. For the current time, I've created a clone at . But I don't think that this project is w

[ANN] Nim0, a playground to learn compiler internals

2021-04-26 Thread spip
If you want to understand how Nim compiler works, start by looking under the hood of the Nim0 compiler, a Nim-compatible toy language with a compiler and an emulator for a RISC CPU. This project is much smaller than the Nim compiler, everything being packed in 5 Nim files. But most important is

Array Difference

2021-04-06 Thread spip
Is the real problem about discoverability in the documentation? [Difference of two sets](https://nim-lang.org/docs/system.html#-,set%5BT%5D,set%5BT%5D) is already there, though not with `seq`. Do we need to improve the documentation search engine ([CTRL]+[F])? Do we need better or more descrip

Nim style guide based on Nimbus experience

2021-02-03 Thread spip
Adding the link to the [Nim style guide](https://github.com/status-im/nimbus-eth2/blob/style-guide/docs/the_style_book/src/SUMMARY.md) because I did not found it in the first post. And dropping a few comments... * This is very good read as it is based on experience. A copy should be availabl

Is there a way to monitor the total memory usage of a Nim app?

2020-12-10 Thread spip
Have you looked at [Nim Memory Profiler](https://nim-lang.org/docs/estp.html)?

Macros that compose (and work well with auto-completion tooling)

2020-12-05 Thread spip
Could you add a reference to @timotheeocur's proposal so that we can compare both?

Strange error message from collections/sets.nim

2020-11-23 Thread spip
Well,ifyo ulik etodro pwhi tespac esatra ndom,Ni mwo n'tbeyo urfri end... Like in many languages!;-)

Why is the implicit `result` so widely used?

2020-11-20 Thread spip
@juancarlospaco, what do you want to show? Is it that [result value is not set when return is used](https://play.nim-lang.org/#ix=2ENS)?

Sample compiler/interpreter (like kaleidoscope/llvm, monkey/go etc)

2020-11-18 Thread spip
Have a look [here](https://github.com/nim-lang/Nim/wiki/Curated-Packages#language) and then you can extend your search to nimble packages...

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-17 Thread spip
@timothee, I know that this thread is talking about exception but perhaps the revised documentation should precise that `defer` works with exception scope. `defer` code won't run at closure iterator end of scope like in the following example. import os proc bar(name: strin

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread spip
when true: block: template main1 = echo "ok1" defer: echo "ok3" echo "ok2" main1() main1() Run > [ok1 ok2 ok1 ok2 ok3 ok3](https://play.nim-lang.org/#ix=2Eqq) But that's not what states the [Nim Manual](https://nim-la

Gedit syntax highlighting.

2020-11-16 Thread spip
@Stefan_Salewski, your [nim.lang](https://raw.githubusercontent.com/StefanSalewski/NEd/master/nim.lang) and [nimdark1.xml](https://raw.githubusercontent.com/StefanSalewski/NEd/master/nimdark1.xml) are well supported in recent Ubuntu. # as root cp nimdark1.xml /usr/share/gtksou

Open-ended slices

2020-11-16 Thread spip
Like in from alpha to omega? `alpha .. X` is bottom-opened range while `Y .. omega` is top-opened range!;-)

Real sets and tables anywhere?

2020-11-16 Thread spip
Well, there is [Nim for Python programmers](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers) and reading at least the [Tutorial](https://nim-lang.org/learn.html) will answer your questions...

Which HTTP server library?

2020-11-15 Thread spip
You could start looking [there](https://github.com/nim-lang/Nim/wiki/Curated-Packages#web) and then extend your search to Nimble packages...

Life is nice...

2020-11-14 Thread spip
... when you see that the Nim compiler is smart enough to [differentiate between an array access and a generic call](https://play.nim-lang.org/#ix=2EbI) while the programmer has difficulties with the syntax... var bar: array[1 .. 1, proc (y: int): int] proc fuzz(x: int): in

Capturing a context variable in public procs

2020-11-13 Thread spip
I've simplified my problem to present it in the forum. Presently, I'm not using a template but a macro because configuration options must be processed before creating the context variable. And I've a few hundreds user functions, split in multiple files that I have to include. Documenting them al

Capturing a context variable in public procs

2020-11-12 Thread spip
Yes, that's [true](https://play.nim-lang.org/#ix=2DXj). Probably simpler than writing the decorating macro, but the documentation comments from the inner procs won't be taken into account by `nim doc`? I'm still thinking about the easiest syntax for users...

Capturing a context variable in public procs

2020-11-11 Thread spip
Inspired by the `with` [macro](https://nim-lang.org/docs/with.html#with.m%2Ctyped%2Cvarargs%5Buntyped%5D), I'm thinking of writing a macro to inject the `ctx` into all `libXXX` calls while walking the AST. But in order for the procs to compile, I would have to write them like: # F

Capturing a context variable in public procs

2020-11-11 Thread spip
For the record, another simple but wrong solution: > It's possible to not use templates if you define your DSL in the math body: template math*(body: untyped) = block: proc `+`*(a, b: Mat): Mat = result = libAdd(ctx, a, b) proc `*`*(a, b: Mat)

publishing a nimble package

2020-11-10 Thread spip
I'm not sure the `nimble publish` method works. Here is the hard way: clone the [nimble packages](https://github.com/nim-lang/packages) repository and update the `packages.json` file with your new package metadata. Them ask for a pull request. The whole process is more documented in the [READM

Capturing a context variable in public procs

2020-11-10 Thread spip
>From what I understand, I will have to go with the macro route and manage the >full DSL language syntax. I have to think about it before jumping as my DSL >can be mixed with Nim code and only the calls to the library needs to get the >context variable (I used a math syntax in my example but the

How to prevent a program from crashing when the "OSError: Too many open files" error occurs?

2020-11-10 Thread spip
Or you can define a file _autocloser_ like shown in when you don't need to keep the files opened.

Capturing a context variable in public procs

2020-11-09 Thread spip
I'm working with an external library that requires passing a context variable to all library calls. As I'm writing a DSL to ease using this library, I'd rather hide this context variable to the user of the DSL. Is there a way to achieve like a closure capture variable for public procs? For inst

signal processing in Nim?

2020-10-28 Thread spip
Look at [science packages](https://github.com/nim-lang/Nim/wiki/Curated-Packages#science)

Is experimental "parallel" compatible with "--gc:arc"?

2020-10-25 Thread spip
I'm playing with a parallel CSV parser and I'm getting `SIGSEGV: Illegal storage access. (Attempt to read from nil?)` during the reduce operation from the parallel parsers, with the stack trace pointing at the GC code: .../Development/fastparse/src/fastparsepkg/fparsecsv.nim(281) r

weird nim parser problem

2020-09-29 Thread spip
[Similar parsing features](https://forum.nim-lang.org/t/6189). Using correct spacing is important in Nim, for the parser and for those who read your code.

stdlib pattern matching feedback

2020-09-23 Thread spip
Have you had a look at the syntax proposed by the different [pattern matching modules](https://github.com/nim-lang/Nim/wiki/Curated-Packages#language)?

Nim's alternative for returning default values using short-circuit-evaluation

2020-09-03 Thread spip
`if` are [expressions](https://nim-lang.org/docs/manual.html#statements-and-expressions-if-expression) and you could rewrite `getTitle` like proc getTitle(m: MyType): string = result = if m.title != "": m.title elif m.foo != "": m.foo elif m.bar != "": m.bar

How to operate on tabular data in Nim?

2020-08-20 Thread spip
Have a look at the Data Science section in the [curated packages](https://github.com/nim-lang/Nim/wiki/Curated-Packages).

Why use range[0..255] instead of char?

2020-08-11 Thread spip
Not in a strongly typed language. A `char` is a character while a `range[0 .. 255]` is an integer in the range 0 to 255. Just like the temperature of my oven can not be interpreted as an amount in my wallet!;-)

How to ensure that all attributes of an object are explicitly set during creation?

2020-07-29 Thread spip
Why is this pragma not the default behaviour? It seems to me that's a better practice to ensure that all fields are initialized by the programmer than relying on the compiler initializing them with a default value. Or at least there could be a compiler define to ensure this default behaviour.

Choosing between generic and specific fn

2020-07-19 Thread spip
Though they look like functions, templates are strange beasts... It seems that your template looks at the symbols it knows when it is instantiated, and it will select the most specific in the known symbols at that time. If both procs have been parsed by the compiler when invoked, it will choose

AsyncSocket seems to be dropping data

2020-07-16 Thread spip
Same assertion error on Linux. ... RCVD #269: 000269 This is message #269 of ∞. Please stay tuned for more. 000269 This is me... RCVD #270: 000270 This is message #270 of ∞. Please stay tuned for more. 000270 This is me... RCVD #715: 000715 This is message #715 of ∞.

Understanding Nim compiler

2020-07-16 Thread spip
Niklaus Wirth's books on compiler design and structured programming are very didactic. Wirth is a great author to explain how things work. And I just discovered that one of the books I read and used a long time ago is now available for free on the Web: [Compiler design in C](https://holub.com/c

tests in the same files as the code

2020-07-15 Thread spip
>From Nim documentation: [Writing >tests](https://github.com/nim-lang/Nim/blob/devel/doc/contributing.rst#writing-tests)