Re: case statement with exceptions

2017-11-10 Thread woggioni
(heavily off topic, just matter of personale taste) I suspected this would have been the proposed solution I started to appreciate exceptions in my Java past, and I still use them in C++ even though my peers seem not to appreciate much having to enclose the opening of a file in a try block.. I

Re: Do we really like the ...It templates?

2017-11-10 Thread Araq
I like them, they make the code even shorter and that's what "lambdas" are all about. I don't really need the "flexibility" of using `a`, `b`, `x`, `y`, `z` here instead but I suppose the ability to nest these suffers.

Re: case statement with exceptions

2017-11-10 Thread jlp765
_(slightly off topic by not addressing directly the case statement, but I think this is the heart of the issue)_ If there was an "Invalid" role, which is the "else" case, type Roles = enum invalid,user,catering,manager,sysadmin then the consumer of this co

Do we really like the ...It templates?

2017-11-10 Thread Stefan_Salewski
Like sortIt() or applyIt() where we are forced to use the it variable name in the condition? When I started with Nim some years ago I thought that that is the only possible way to do it in Nim -- but I always regard it as very ugly. I just remembered that I tried successfully to use a custom va

case statement with exceptions

2017-11-10 Thread woggioni
while this code compiles fine from strutils import `%` type Roles = enum user,catering,manager,sysadmin converter toRole(s : string): Roles = case s of "user": return Roles.user of "catering":

Re: Heterogeneous object pool with Timed Eviction

2017-11-10 Thread cdome
I had a similar problem in the past and I have considered a similar solution. However, I ended up using one custom fixed size hash table with open addressing. Idea is that table once filled up, start throwing away one element everytime another one needs to be inserted. Table doesn't ever grow. I

Hiding sideeffect from compiler

2017-11-10 Thread cdome
Hi, I am actively using Nim's side effect tracking system and marking procs with noSideEffect pretty much everywhere. I have external requirement not to have side effects and Nim helps here quite a bit. However, I have place in a code that logically I don't have side effects, but physically I a

Heterogeneous object pool with Timed Eviction

2017-11-10 Thread mratsim
In the past 2 days I've been researching various ways to avoid expensive allocations/deallocations in tight loops on GPU, by reusing memory. Apparently this is also a recurrent issue in game programming so I'd like to share my approach and request for comments. My use-case: * I allocate

Re: What's happening with destructors?

2017-11-10 Thread mratsim
dataRef to have the deallocation of the data managed by Nim GC. data for normal use through foo[10] (thanks to UncheckedArray). Yes data is public because in my use case this is only used internally, and getter/setter would just add boilerplate for no gain. Same thing for len. Regarding copy, j

Re: real inline for inline procs or converters

2017-11-10 Thread Udiknedormin
@jxy Well, I wanted to make a call optimization library, actually. Including various recursion optimizations (I know there is memo but it provides only one opt method and even my pull request to it was never accepted). Inlining is, of course, one of the possible optimizations (so I guess it's a

Re: What's happening with destructors?

2017-11-10 Thread Udiknedormin
@mtrasim I've already said it's a bad idea (even on many architectures on which it's possible). And even if you don't really have a heap, it doesn't mean you couldn't use dynamic memory if a language supports custom allocators. You can provide a memory pool on a stack, that's what I actually di

Re: Why splitWhitespace() from strutils lacks maxsplit parameter?

2017-11-10 Thread Udiknedormin
Mine version would not. The old code can't use parameters non-existing then so you'll just have to add another split argument which works like splitWhitespace does today and then make splitWhitespace an alias for some split call (with depreciation annotation) for backwards compatibility.

Re: Confusion with Generics and nim typesystem.

2017-11-10 Thread jangko
this is another generics typerel bug that should be reported.