wNim - Nim's Windows GUI Framework

2022-01-14 Thread oyster
I finished a project by using `Layout DSL` ( the function `goodLayout` in ), however the code is very long I used `Layout DSL` because I still can't master `autolayout` well. Can anyone point out what is the problem in my following

Suppressing non-exported fields in nim doc

2022-01-14 Thread cantanima
Is there some way to prevent field `b` from being documented when using `nim doc`? Or is this the expected behavior? type T* = object a*: int b:float Run Likewise, should `a` be printed by the documentation as `a*`?

How can I implement a conditional access operator?

2022-01-14 Thread geekrelief
I have no idea how to fix the issue with calling a proc with args using only templates. I tried using the `*` operator: like import std / [macros] {.hint[Pattern]:off.} ma

Nim Community Survey 2021

2022-01-14 Thread Yardanico
If you were being sarcastic about that part, then maybe you misunderstood it a bit - users getting older on average can mean that there are not enough new Nim users and that new Nim users are typically older than existing Nim users (all on average of course).

Nim Community Survey 2021

2022-01-14 Thread xioren
No I understood what he meant. Just pointing out the humor in that sentence when taken at face value.

Nim Community Survey 2021

2022-01-14 Thread xioren
> we are noticing a trend where our users are on average a bit older than the > year before

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

How can I implement a conditional access operator?

2022-01-14 Thread geekrelief
Do you know how I could get this chaining to work with a proc that takes args? In the example, `foo` works, but `bar` doesn't.

cannot instantiate: 'T' with importcpp generic

2022-01-14 Thread bj0
So after a little more work I've gotten to this (below): I'm stuck at trying to figure out how to pass a callback into a cpp function. I have tried a few different things: adding cdecl, ptrs/no ptrs. The code provided produces the error: > error: cannot convert 'Tins::PDU' to 'Tins::PDU*' in ar

Variable prints out its type correctly, but can't access members and I can't figure out why

2022-01-14 Thread Ethernaut
This one works! The only difference is this line right before the last block: when owner is ThingContainer: Run The template still automates going through each type index and returning the right thing (in reality there will be dozens of types, so automating this is a

Novice Question: Implement the Step functionality in VBA

2022-01-14 Thread Symb0lica
Version with only one yield iterator myStep(a, b:int):int = let step = if a < b: 1 else: -1 var i = a while (if 1 == step: i <= b else: i >= b): yield i i += step Run

How can I implement a conditional access operator?

2022-01-14 Thread geekrelief
Thanks! I found the relevant section in the manual now:

Novice Question: Implement the Step functionality in VBA

2022-01-14 Thread lscrd
Equivalent to your solution, but more concise: iterator mystep(a, b: int): int = for i in countup(a, b): yield i for i in countdown(a, b + 1): yield i Run

Novice Question: Implement the Step functionality in VBA

2022-01-14 Thread freeflow
That's a neat solution but isn't appropriate in this case. The iteration has to be X1 to X2 because the x values are tied to Yvalues and your suggestion would change the x,y pairs. In the meantime I've come up with the ghastly apparition of iterator myStep( a,b: int):int=

Novice Question: Implement the Step functionality in VBA

2022-01-14 Thread freeflow
I'm converting Advent of Code solutions from VBA (twinBasic) to Nim I have a bit of a headscratcher when it comes to implementing the Step functionality in 'for x to y step z' because in VBA step can be a positive or a negative value wheres nim uses countup or countdown iterators with the step

cannot instantiate: 'T' with importcpp generic

2022-01-14 Thread ElegantBeef
Yes it's listed under the method call syntax [here](https://nim-lang.org/docs/manual.html#procedures-method-call-syntax)

How can I implement a conditional access operator?

2022-01-14 Thread ElegantBeef
In Nim that's called a typeclass.

Novice Question: Implement the Step functionality in VBA

2022-01-14 Thread ElegantBeef
If I'm write in my assumption of the challenge `for i in min(a, b)..max(a, b)` should work fine.

cannot instantiate: 'T' with importcpp generic

2022-01-14 Thread bj0
I was using `pdu.rfind_pdu[IP]()`. Switching to `rfind_pdu[IP](pdu)` or `pdu.rfind_pdu[:IP]()` worked, thanks! Is the special `:IP` syntax mentioned in the manual somewhere?

How can I implement a conditional access operator?

2022-01-14 Thread geekrelief
Thanks for the tip about wrapnils. That's cool I didn't you know you could do this without genericizing it: template `?.`(a: ref | ptr | pointer, b): untyped = Run What's this called? The or'ing of types.

How can I implement a conditional access operator?

2022-01-14 Thread geekrelief
Thanks for replying. I created a working PR before I saw your reply. I saw the issue with precedence as well and mattaylor the maintainer added `.?` as an alternative for `?.` for higher precedence. I changed the implementation to `untyped` instead of using a `proc` type. So this works:

Nim 1.6.2 : silent program rejection

2022-01-14 Thread ElegantBeef
It seems the generic cache is not respected for this example which results in an endless loop. The following is enough to cause a seg fault. type PCset[T,V] = object of RootObj PTa[V] = object of PCset[PTa[V], V] var a: PTa[int] Run

Variable prints out its type correctly, but can't access members and I can't figure out why

2022-01-14 Thread Ethernaut
Thanks for you thoughtful reply! Unfortunately, won't using ref objects also cause the objects to not be stored contiguously in memory anymore? If you look at my obtuse example (sorry!) you'll see that the Container doesn't actually carry the Thing, just a handle to it (it needs to be a handle,

profiler for mac?

2022-01-14 Thread treeform
I have written a command line sampling profile for nim that works on Windows, Linux and ... with some effort Mac. To use it on mac you would have to generate a self signed certificate and code sign the hottie executable. Which is very annoying.

Nim 1.6.2 : silent program rejection

2022-01-14 Thread Hlaaftana
The existing VS Code plugins do not report a compiler segfault. The more recently updated one should report other crashes, but I don't think it reports segfaults.

How can I implement a conditional access operator?

2022-01-14 Thread geekrelief
I'll take a look and report back if I make any progress on it.

Nim 1.6.2 : silent program rejection

2022-01-14 Thread Sixte
Well, no segfault was reported. The compiler "died" silently. Linux Mint, VSCode.

Nim 1.6.2 : silent program rejection

2022-01-14 Thread Hlaaftana
It's not compiling flawlessly, the compiler is segfaulting. [Similar issue](https://github.com/nim-lang/Nim/issues/17303)

How can I implement a conditional access operator?

2022-01-14 Thread Hlaaftana
You could write this as a macro, but it's also possible as a template and it's clearer this way. Template substitution works for field access, which makes this possible. template `?.`(a, b): untyped = let tmp = `a` # ensure `a` isn't evaluated twice if tmp.isNil:

Nim 1.6.2 : silent program rejection

2022-01-14 Thread Sixte
I just downloaded Nim 1.6.2 via choosenim. The tiny program type PCset[T,V] = object of RootObj cnt : V pc : ptr T PTa[V] = object of PCset[PTa[V],V] dummy : int proc show[V](a : PTa[V]) = echo a.cnt # #[ proc runb

Nim Community Survey 2021

2022-01-14 Thread Hlaaftana
> we are noticing a trend where our users are on average a bit older than the > year before This implies Nim usership has stagnated which makes sense. 1.6 wasn't a huge release since IC wasn't included, even that wouldn't compare to something like 1.0 in terms of attention. Though from what I k

How can I implement a conditional access operator?

2022-01-14 Thread planetis
Maybe the experimental [dotOperators](https://nim-lang.github.io/Nim/manual_experimental.html#special-operators-dot-operators) can help you. And please let me know how it went.

How can I implement a conditional access operator?

2022-01-14 Thread geekrelief
I'm looking for some advice on how to implement a proper conditional access operator. The one in elvis: is limited to using a proc for its `right` argument. I want to be able to chain the `?.` operator, e.g.: `data?.obj.?prop` So I was

Nim Community Survey 2021

2022-01-14 Thread miran
Here are the results of the survey:

llvm wrap

2022-01-14 Thread arnetheduck
Nice! You might be interested in which provides a full JIT for Nim code using LLVM

llvm wrap

2022-01-14 Thread rforcen
in the context of a float expression evaluator, i've been toying with llvm to measure performance ratio against a pure nim pcode solution (expression.nim), in some cases such ratio exceeds 50, attached files cover * basic algebraic expression evaluation with * parameter passing mechanism a

Variable prints out its type correctly, but can't access members and I can't figure out why

2022-01-14 Thread Ethernaut
Sorry, I posted that before your reply was visible! Not on computer now, will take a look a the suggestions tomorrow, thanks!

Man pages?

2022-01-14 Thread PMunch
I tried to remove as much of the embedded HTML as possible a while back, so if you haven't looked at it for a while it might be quite a bit better than you remember. My goal was to have the compiler only output JSON, and then have the HTML documentation builder read that and generate the HTML pa

Variable prints out its type correctly, but can't access members and I can't figure out why

2022-01-14 Thread Ethernaut
I wrote down an approximation of what gets expanded by the template, and I think I get it now let item = thingA_list[7] if item.owner_type == 0: let owner = container_list[item.owner_index] # item is ThingContainer # body echo typeof(owner) ec

Variable prints out its type correctly, but can't access members and I can't figure out why

2022-01-14 Thread enthus1ast
you can test for a given type with `of`. I also think the objects must be refs in your case: type Thing = ref object of RootObj ThingA = ref object of Thing text:string ThingB = ref object of Thing value:float

Variable prints out its type correctly, but can't access members and I can't figure out why

2022-01-14 Thread enthus1ast
Please re read my post above, the key changes are: * ref types * test for types with `of` * type conversion with eg: ThingA(thing)