choosenim x64

2021-08-03 Thread ingo
In a bin of my home dir where I keep all the little things I make. How it got there, I don't remember/understand, it where just the nim executables. My guess, choosenim's fault. Thanks.

Mac GUI

2021-08-03 Thread AIR
I added `newEditMenu` and `newFormatMenu` procs to auto-generate Edit and Font menus. Uploaded `editor.nim` to showcase them. Remember to bundle the app so the menus are accessible. Edit menu has: * Undo * Redo * Cut * Copy * Paste * Select All Format menu has: * "Show Fonts"

Is it possible to pass a list/array of types to a function?

2021-08-03 Thread slangmgh
https://github.com/yglukhov/typelists

Mac GUI

2021-08-03 Thread AIR
> BTW, shortkey commands like Cmd-S, Cmd-O, Cmd-N need to be set up separately? In general, yes, as part of creating the menuitems. I'm thinking of approaching this a bit differently, though. What would your thoughts be if I created a proc that would create the menu for you, along with the asso

choosenim x64

2021-08-03 Thread dom96
Out of curiosity, where was it and how did it end up there? Was it through a custom Nimble directory setting?

Is it possible to pass a list/array of types to a function?

2021-08-03 Thread hugogranstrom
If you really don't want to use a macro you could create a dummy variable of a tuple of the types you want like this: proc niceSize(a: tuple): int = for f in a.fields: result += sizeof f var temp: (int64, int8, int16) echo niceSize(temp) Run

Is it possible to have generic object members?

2021-08-03 Thread alexeypetrushin
It's also possible to use JsonNode as a quick way to storage any object. It would be not very efficient and the type of original object would be erased, you would have data only, but if it's not used in bottleneck it should be ok.

How to rewrite nim programming langauge to be pythonic as possible?

2021-08-03 Thread alexeypetrushin
> Similarly pythonicity is assumed uninterrogatedly to be synonymous with > ergonomicity Just a side note... I didn't meant to promote Python. I don't like Python and its practices. Inconsistent names shortcuts, inconsistent function calling `fn(obj)`, `obj.fin()`, `np.fn(obj)` etc. > but if i

Is it possible to have generic object members?

2021-08-03 Thread tsojtsoj
"using func for absolutely everything defeats the point of using it in the first place" My idea is that I normally never want side effects (so no procs). Everything that is necessary should be passed into the function, where I can immediately see what a specific function can affect. But someti

Is it possible to pass a list/array of types to a function?

2021-08-03 Thread tsojtsoj
I want to achieve something like this: # this works perfectly fine: func hello(T: typedesc): int = sizeof T echo hello(float64) echo hello(float32) # this doesn't work: func funfunfun(Ts: openArray[typedesc]): int = for T in Ts:

Is it possible to have generic object members?

2021-08-03 Thread hugogranstrom
Well, the point of keeping track of side-effects is that you keep track of them... It's the "leaf functions" (functions that doesn't depend on other functions) that should be funcs, and then the rest of the functions can be funcs or procs depending on **what they actually are**. For example the

choosenim x64

2021-08-03 Thread ingo
Ah. That did it. A stray Nim found and removed. Thanks.

Is it possible to have generic object members?

2021-08-03 Thread tsojtsoj
If I made this a proc, then all other functions that call this proc at some point also need to be procs. And I like to have the compile time checks of sideeffects for more complex functions that where it is harder to see, if they actually have side effects. But I found a better solution anyway (

choosenim x64

2021-08-03 Thread moigagoo
For completeness, it's `get-command nim` on Windows (PowerShell).

choosenim x64

2021-08-03 Thread dom96
Run `where nim` or `which nim` (Linux/MacOS) to see where the `nim` comes from.

Is it possible to have generic object members?

2021-08-03 Thread hugogranstrom
You do you and if it works, nice! But I personally wouldn't use casting when safer alternatives are available though, but you do you :) Also something I'm not understanding: func getUniqueId(): int = {.cast(noSideEffect).}: var idCounter {.global.} = 0

Proposed table changes - get and getOrDefault

2021-08-03 Thread cblake
After posting this, I thought of a maybe better name: `withIt` that tracks more a `sortedByIt` convention applied to `withValue` instead of `mgetOrPut` style naming. The name is updated in the linked-to `adix/lptabz.nim` example impl & this post is to shrink confusion.

Is it possible to have generic object members?

2021-08-03 Thread tsojtsoj
Thanks! I tried this myself, but I got stuck, so this will definitely help understanding macros :D Though, I think I will use this solution, as I will need the `func typeId[T]()` anyway. I am not sure if it is all sound, but it at least seems to work. And while it pretty inelegantly does all th

Is it possible to have generic object members?

2021-08-03 Thread hugogranstrom
It ain't pretty but it works: 🙃

choosenim x64

2021-08-03 Thread ingo
How do I remove choosenim completely from windows? I removed the choosenim dotfile/dir toolchains etc., the .nimble bin dir. cleaned out the path environmental variable. Downloaded a fresh 1.4.8 zip and put it in a warm place and ran finish.exe The result of running nim is: >nim

Is it possible to have generic object members?

2021-08-03 Thread hugogranstrom
Sadly it doesn't work out of the box but it is possible using macros to generate the `ImportantStuff` type and `get` proc automatically. type ImportantStuff = object littleMember_int: seq[int] littleMember_float: seq[float] littleMember_ComponentTypeA: seq[Com

Playing with CPU caches

2021-08-03 Thread planetis
because your component's already pretty compact. There is no cache trashing, since you use every member field. Note in ECS is not about this low level of granularity where you would split it's direction to different components. Although that would make sense if you plan to do manual vectorizatio

Mac GUI

2021-08-03 Thread Neodim
AIR, thank you for you reply and for your efforts: I really believe that good GUI libs make our lovely Nim-lang more stronger and popular! Well, menu items behavior was not obvious but now it is fine. BTW, shortkey commands like Cmd-S, Cmd-O, Cmd-N need to be set up separately? Regarding NSTabl

Playing with CPU caches

2021-08-03 Thread yglukhov
@demotomohiro thanks, that nails it. So basically my AoS variant flushes 4 times more memory than actually needed. I guess it's safe to conclude that it's better to not interleave write memory with read memory.

How to rewrite nim programming langauge to be pythonic as possible?

2021-08-03 Thread shirleyquirk
> Copying bad design is not good design. > >> Ok making hammer by copying bad hammer design is not good. Seems like a some >> minor point that should not go as the first statement. This is a major point, both in hammer design and in language design. Even with a mature technology like hammer desi

Playing with CPU caches

2021-08-03 Thread demotomohiro
In `testSOA`, only the content of seq `m` need to be written to main memory . I think in `testAOS`, not only field `m` in object S, but also field `x, y, z` need to be written to main memory because they are also likely in the cache line containing field `m`. According to this wikipedia entry:

Requests library

2021-08-03 Thread enthus1ast
What features do you need?

Is it possible to have generic object members?

2021-08-03 Thread tsojtsoj
So the use case is a simple entity component system. What shirlyquirk posted comes quite close to what I want, and I think something like this is what I'll use. However, this requires me to manually "register" all component types in the ComponentManager, which I wanted to avoid. Basically I hop

Playing with CPU caches

2021-08-03 Thread Stefan_Salewski
I think that your test is very special in that you really use all the fields of your object struct in your test. I would assume that for a larger object, with more fields that are not actually used in your tests loops, that fields would pollute the data cache.

Playing with CPU caches

2021-08-03 Thread mratsim
In general SoA is more cache-friendly than AoS and lend itself more to SIMD optimizations. This is why in video processing, the preferred format is YUV or YV12 instead of RGB. Now regarding your code, hardware prefetchers can follow up to 12 forward streams. It's very easy to catch the pattern

Playing with CPU caches

2021-08-03 Thread yglukhov
While migrating our [game engine](https://github.com/yglukhov/rod/) to ECS architecture we went out to validate some simple ideas about CPU caches, and were a bit surprised. I'm hoping someone can explain what's happening here. import random, std/monotimes const MAX = 9000

Requests library

2021-08-03 Thread 04xhlnat
thank you for answering

Is it possible to have generic object members?

2021-08-03 Thread shirleyquirk
import json let c = %*[3.14,"pi",3] proc get[T](o:JsonNode,i:int):T = when T is float: o[i].getFloat() elif T is int: o[i].getInt() elif T is string: o[i].getStr() echo c.get[:float](0) echo c.get[:string](1) echo c.get[:int](2) Run ?

Is it possible to have generic object members?

2021-08-03 Thread hugogranstrom
As @xigoi said, it's the object itself that is generic, not its fields. This is the correct code: type ImportantStuff[T] = object littleMember: seq[T] func get[T](a: ImportantStuff[T], i: int): T = a.littleMember[i] var c: ImportantStuff[int] dis