can Parsing Expression Grammar mechanisms replace the absence of reader macros in Nim??

2022-11-09 Thread Hlaaftana
I haven't heard of string macros in Julia so I looked it up and based on [this](https://stackoverflow.com/questions/26600143/why-do-string-macros-in-julia-use) Nim does have something similar with [generalized raw string literals](https://nim-lang.org/docs/manual.html#lexical-analysis-generalize

Howto: reinterpret a contiguous region/chunk of memory as a sequence of a certain type?

2022-11-09 Thread GavinRay
Perfect, thank you! The `[]` syntax is very familiar, reminds me of the syntax that D uses for "slices", which are non-allocating views over pointers. I like it =)

can Parsing Expression Grammar mechanisms replace the absence of reader macros in Nim??

2022-11-09 Thread Araq
Ok, sure, good. But beware that your Scheme patterns might not apply in Nim. Just because you need a reader macro in Scheme doesn't mean that you need one in Nim. Nim already comes with a concise syntax, you don't need to hack around it.

wrapping c++ function - cannot instantiate 'T2'

2022-11-09 Thread mantielero
@sls1005 thanks a lot for that. But for some reason is failing. I got: ... proc dcast*[T](this: Handle[auto] ):Handle[T] {.cdecl, importcpp: "\'0::DownCast(@)".} ... Run and import occt var aPnt1: Handle[Geom_Point] var aPnt2, aPnt3:

can Parsing Expression Grammar mechanisms replace the absence of reader macros in Nim??

2022-11-09 Thread nobody667
I was programming in scheme until I had to go low-level and realized that I was doing a big mess and that language is not suited for going down in the system. well, having Nim the same metaprogramming power of lisp/scheme is wonderful as PEGs can replace the reader macros @Araq , I believe that

can Parsing Expression Grammar mechanisms replace the absence of reader macros in Nim??

2022-11-09 Thread Araq
Yes. But before you take that route see if Nim's parser can already do what you need. For example, there are user definable operators and there is a general mechanism for passing blocks of code around.

can Parsing Expression Grammar mechanisms replace the absence of reader macros in Nim??

2022-11-09 Thread nobody667
I know that Nim does not have proper reader macros as most LISPs have, neither String macro as Julia has. but I could just write a compile-time parser and generate Nim code which will be compiled, am I right? * * * I found a PEG library for Nim: can such mechani

Howto: reinterpret a contiguous region/chunk of memory as a sequence of a certain type?

2022-11-09 Thread Dabod
` let p = Page() for s in p.getSlots[]: echo s ` Run

Howto: reinterpret a contiguous region/chunk of memory as a sequence of a certain type?

2022-11-09 Thread GavinRay
Ah, I didn't realize it was so simple as to just return the address of the first pointer Are `ptr` types iterable in Nim? Could I do something like: for each slot_ptr in slots: do_something(slot_ptr) Run Thanks all =)

Howto: reinterpret a contiguous region/chunk of memory as a sequence of a certain type?

2022-11-09 Thread Dabod
Since the `data` is a fixed size array, this way might help const PAGE_SIZE = 4096 type Slot = object size: uint16 offset: uint16 type ByteData = array[PAGE_SIZE - (sizeof(uint16) * 2), byte] type SlotData = array[sizeof(ByteData) div sizeof(Slot), Sl

Howto: reinterpret a contiguous region/chunk of memory as a sequence of a certain type?

2022-11-09 Thread dlesnoff
>From what I understand from the C++'s implementation, the data array removes >the space that pageId, numSlots and freeSpace takes, so here it should rather >be: type Page = object pageId: uint32 numSlots: uint16 freeSpace: uint16 data: array[PAGE_SIZE - size

nim name origin?

2022-11-09 Thread sekao
Yep, I'm American and "nimrod" definitely has a vaguely negative connotation in my mind. I didn't even know why until I someone mentioned bugs bunny and all the childhood memories came rushing in :D

nim name origin?

2022-11-09 Thread zio_tom78
To add some amusing information, I remember that the reason why Nimrod was renamed to Nim was because nowadays the Biblical reference is lost in the US world, and the term is now viewed as an insult because of a Bugs Bunny cartoon. (Being an Italian, I too was unaware of this!) See here:

nim name origin?

2022-11-09 Thread adrianv
when I first found nim (Nimrod at that time) the name remembered me at a scene from a Bugs Bunny cartoon where Elmer Fudd was hunting Bugs (what else) and Bugs Bunny called him "mighty hunter Nimrod". So I thought cool - Nimrod is a language for hunting bugs.

nim name origin?

2022-11-09 Thread scarf
> it would have to be named after a god. :-) interesting, reminds me of [holyc](https://harrison.totty.dev/p/a-lang-design-analysis-of-holyc)