Question of modeling with type system

2024-01-25 Thread Araq
There are libraries that offer macros to do that and then there is and earlier attempts.

Is `concept` similar to `interface` / `trait`?

2024-01-25 Thread aiac
If there is a translator for transforming an odd way of speaking into normal answers , it can be great

Question of modeling with type system

2024-01-25 Thread geohuz
Hi guys, I've been rewriting my project to nim, it is written in rescript(a modified version of the OCaml compiler), I have a little type model like below: type equal = | EqualStr(string) | EqualInt(int) type cmp = | LessThan(int) | GreatThan(int)

Is `concept` similar to `interface` / `trait`?

2024-01-25 Thread Araq
Who knows, unfortunately web search engines have yet to be invented.

Is `concept` similar to `interface` / `trait`?

2024-01-25 Thread aiac
Are there any libraries using `concept` ?

Struggling to understand use of ptr object Types

2024-01-25 Thread Araq
You are confused about absolutely nothing. `create` does exactly what you think it does, namely `cast[ptr T](alloc0(sizeof(T) * size))` and it's just that you passed the wrong `T`. You can conclude from that that `ptr object` is to be avoided but in reality it's just that `create` is not very us

Argon2 in Pure Nim.

2024-01-25 Thread xioren
Okay that makes sense thank you. So it's a question of efficiency rather than correctness. I will look into threadpool.

Argon2 in Pure Nim.

2024-01-25 Thread mratsim
You're creating `timeCost *syncPoint*parallelism` threads. Creating a thread is very costly and need to be amortized, a threadpool reuses them. You can do at least 5 xor-shift-rotate-add while waiting for the OS to create a _[single](https://forum.nim-lang.org/postActivity.xml#single) thread

Struggling to understand use of ptr object Types

2024-01-25 Thread jhwbarlow
Wow quick replies, thanks :) Is `create()` not just a convenience wrapper around `alloc()`? It looks like it just takes `sizeof(T)` for you to avoid you doing that yourself and then casts it nicely for you? cast[ptr T](alloc0(sizeof(T) * size)) Run I was on that trai

Struggling to understand use of ptr object Types

2024-01-25 Thread Araq
`Cat.create()` creates a `ptr Cat` type, `DangerousCat.create()` creates a `ptr DangerousCat` type which is a pointer to a pointer so the assignment to `dangerCatSigSegV.name` can only fail.

Struggling to understand use of ptr object Types

2024-01-25 Thread mratsim
A `ptr object` needs to be allocated first with `alloc`, `alloc0` and then initialized, like in C. There is no convenience for constructor-like procs, it's an escape hatch for low-level programming and if you need that escape hatch it's likely that even if the stdlib tried to provide sugar for y

Nim safety features like Zig & Rust?

2024-01-25 Thread mratsim
If you overengineer for generality (allocators to cover each use-cases), you're not specializing, on the contrary. And you're going straight into architecture astronauting land and Java's Bean Factory Handler Manager ... *

Struggling to understand use of ptr object Types

2024-01-25 Thread jhwbarlow
Hi All, New to Nim (background is Go, Python, Java/C#, very rusty C) and struggling to understand the use for `ptr object` types. The docs say > As a syntactical extension, object types can be anonymous if declared in a > type section via the `ref object` or `ptr object` notations This seems

Argon2 in Pure Nim.

2024-01-25 Thread xioren
Sorry to belabor the point but getting this right is important to me and I am unable to verify what you guys are saying. I really can't see how using createThread is giving me the WRONG number of threads. From the documentation: import std/locks var thr: array[0..4, T

Custom constructors

2024-01-25 Thread lou15b
Since the OP expressed a desire for "constructors", and I remember reading similar wishes in a number of posts a while back, perhaps the following tweak to the pattern would fill the need for those in need of "real" constructors: proc construct(_: typedesc[YourType], ): YourType

https://www.facebook.com/DrOzBiohealCBDGummiesCost/

2024-01-25 Thread DrOzBiohGummi
➢ Product Name — Dr Oz Bioheal CBD Gummies ➢ Main Benefits — Dr Oz Bioheal CBD Gummies ➢ Composition — Naturl Organic Compound ➢ Rating: —⭐ ➢ Availability — Online ➢ Where to Buy – Click Here to Rush Your Order from the Official Website ➢ Hurry Up - Limited Time – Order Now Dr Oz Bioheal

Custom constructors

2024-01-25 Thread Araq
> The proc is of dubious merit, but you can see how easily we've called the > proper init function for our given type here. Yes but instead of `init(T); setlen L` it should have been `init(T, L)` for efficiency and then the real problem shows up which is "what is the generic all encompassing si

chronos 4.0

2024-01-25 Thread Isofruit
> ORC has not yet been released at a quality level that is compatible with our > needs - we keep an eye on it and as mentioned elsewhere, the chronos core is > cycle-free meaning it's at least theoretically can work with ARC, so when ORC > reaches the point of usability, we'll be in a good spot.

punctuations rituals

2024-01-25 Thread ingo

punctuations rituals

2024-01-25 Thread ForeverGood
@termer? they will NOT know what to talk about but be afraid. Source-to-source compiler

Custom constructors

2024-01-25 Thread lim1999
Dear all, Thanks for all the replies so far. Insightful discussion indeed. I will retreat for a awhile to experiment with the code, and also to do the job that pays my bills :-) Till very soon

Custom constructors

2024-01-25 Thread lim1999
That's a beautiful pattern! Although I don't yet understand the comments in the snippet. I will try to figure it out by experimentation. Thanks a lot.

Custom constructors

2024-01-25 Thread PMunch
I mean just something as simple as: proc something[T](x: T, y: int): T = result = init(T) result.setLen x.len for i in result.mitems: i = y Run Demonstrates why `init` is better than `initT`. The proc is of dubious merit, but you can see how e

Custom constructors

2024-01-25 Thread ElegantBeef
is a `Rect` agnostic guillotine square packer. Ideally this would work on any type but the concept needs expanded, as it is it should work with a Rect made of any builtin type. My library Gooey constraints `Vec` s to the