Re: Efficient way to validate function arguments

2019-11-08 Thread drkameleon
I've thought about using hashes, though I haven't tried it yet. I'll let you know!

Re: Efficient way to validate function arguments

2019-11-08 Thread drkameleon
Here is the interpreter (and language) I'm talking about: [https://github.com/arturo-lang/arturo](https://github.com/arturo-lang/arturo)

Re: Efficient way to validate function arguments

2019-11-08 Thread mratsim
If you have less than 65k values (2^16) just use Nim sets. import strformat type RuntimeTag = enum SV # stringValue IV # integerValue AV # arrayValue type AllowedInput = set[RuntimeTag] proc validate(x: RuntimeTag, req: AllowedInput)

Re: Efficient way to validate function arguments

2019-11-08 Thread foldl
Multiple dispatch. Maybe you can create a hash signature for each combination of arguments. Then req becomes a hash set or a dict depending on your design.

Efficient way to validate function arguments

2019-11-08 Thread drkameleon
_(I 've also posted the following on SO, but I guess it's a more Nim-specific question)_ **Before saying anything, please let me make it clear that this question is part of my work on an interpreter - and has nothing to do with validating a Nim proc 's arguments.** Let's say we have an enum of