Re: How to check an auto type parameter in a proce

2018-09-27 Thread mratsim
Feel free to ask on IRC then. The only way to progress fast in Nim is by trying and then asking otherwise you will lose time. I remember learning like throwing eggs on a wall a see what sticks (and then raising bug reports for static and generic types). Now from all your posts, I think the

Re: How to check an auto type parameter in a proce

2018-09-27 Thread kcvinu
I did not meant that you attacked me. May be you are right. I am asking questions in the wrong way. I think i was little Impatient at that time. I should need to try the trial and error method instead of asking in the forum. > It's not the first time on this forum that somebody has posted a

Re: How to check an auto type parameter in a proce

2018-09-27 Thread kcvinu
Thanks. May it was my problem because, i was little frustrated when i cant find what i was looking for. I know, i have asked too many queries in different threads. But actually, the suggestions from others were not satisfied me, but it was my fault, not their fault. I think its better for me to

Re: How to check an auto type parameter in a proce

2018-09-26 Thread miran
> Sorry for disturbing you with my questions. Next time, when i face any > obstacles in nim coding, i will insist myself to not to ask in this forum. Please read the wiki article I linked. Not only that you shouldn't react like I was personally attacking you, but you you should see that the

Re: How to check an auto type parameter in a proce

2018-09-26 Thread mratsim
Asking in the forum is not an issue, but what miran said is that he feels like you might be trying to solve your issue at a low level while we could solve the actual bigger problem. (correct me if I'm wrong @miran). 1\. Auto and Any type for input params are usually not needed, using a generic

Re: How to check an auto type parameter in a proce

2018-09-26 Thread kcvinu
I don't want to use python because these reasons. 1. I need to use a third party app to make exe from python code. (I think python is not for windows) 2. Compiled exe is very large. A normal hello world gui app will size around 4-5 MBs. 3. Execution speed. I will sure consider the

Re: How to check an auto type parameter in a proce

2018-09-26 Thread kcvinu
Sorry for disturbing you with my questions. Next time, when i face any obstacles in nim coding, i will insist myself to not to ask in this forum.

Re: How to check an auto type parameter in a proce

2018-09-26 Thread miran
> [XY problem](https://en.wikipedia.org/wiki/XY_problem)

Re: How to check an auto type parameter in a proce

2018-09-26 Thread Stefan_Salewski
> I just tested it and it worked. Is there any problems using this method ? Of course you can cast refs or ptrs to int and store it in a seq of ints. But how do you do the bookkeeping? When you retrieve a value from your list, then its looks like an int. So how do you decide if it may be a ref

Re: How to check an auto type parameter in a proce

2018-09-26 Thread kcvinu
> Three separate seqs with different data types and same name? Obviously makes > not much sense. Ha ha.. In my sense, it was like ; "Hey compiler, this is > 'one' seq but the data type is one among three. If the input value is int, > then treat this seq as a seq[int]. And when the input value

Re: How to check an auto type parameter in a proce

2018-09-26 Thread Stefan_Salewski
miran I think your explanation is still too short for beginners... One should know that proc foo(a: seq[int|float|char]) Run is basically a short form for definition of three separate procs: proc foo(a: seq[int) proc foo(a: seq[float) proc foo(a:

Re: How to check an auto type parameter in a proce

2018-09-26 Thread miran
> This gave me error. > > `var mySeq : seq[ int | float | string]` This cannot be used for declaring a variable, but you can use it for arguments in a function: proc foo(a: seq[int|float|char]): string = return $a[0] echo foo(@[3, 5, 7]) echo foo(@[3.5, 5.7,

Re: How to check an auto type parameter in a proce

2018-09-25 Thread tim_st
Yes, int | float | string is not a concrete type, it's just to match a signature at compile time. You can use an object variant ([https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants](https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants) )

Re: How to check an auto type parameter in a proce

2018-09-25 Thread kcvinu
proc myProc2(a : int | float | string) = discard Run Thats a great work around. Thanks for it. One question. This gave me error. var mySeq : seq[ int | float | string] Run Any work around for this ?

Re: How to check an auto type parameter in a proce

2018-09-25 Thread kcvinu
This is my requirement. I am writing a combobox class. This class has an item property. It contains a seq. One wants to insert int or string or float, or even a window handle too. After a lot of experiments, i decided to make that seq[string] type and if i convert the input data to string with

Re: How to check an auto type parameter in a proce

2018-09-25 Thread kcvinu
Thanks for the reply, but i want to check in runtime, not compile time.

Re: How to check an auto type parameter in a proce

2018-09-25 Thread tim_st
Maybe the following is sufficient: proc myProc(a : auto) = when a is int: echo "got an int" elif a is string: echo "got a string" elif a is float: echo "got a float" proc myProc2(a : int | float | string) = discard myProc(1) myProc("abc")

Re: How to check an auto type parameter in a proce

2018-09-25 Thread Hlaaftana
It's [typeinfo](https://nim-lang.org/docs/typeinfo.html) not typetraits and instead of `auto` you'd need to use the `Any` type. I recommend you don't use this module and simplify your code to not use types at runtime. Do note that if you want to check at compile time all you need to do is use

Re: How to check an auto type parameter in a proce

2018-09-25 Thread demotomohiro
If type of `a` is really `int`, `float` or `string` you can write code like this: proc myProc1(a: int) = echo "int: ", a proc myProc1(a: float) = echo "float: ", a proc myProc1(a: string) = echo "string: ", a proc myProc(a: auto) =

Re: How to check an auto type parameter in a proce

2018-09-25 Thread lotzz
the module typetraits might be able to help you

Re: How to check an auto type parameter in a proce

2018-09-25 Thread kcvinu
Yes.

Re: How to check an auto type parameter in a proce

2018-09-25 Thread lotzz
Do you need to know the type at runtime?

How to check an auto type parameter in a proce

2018-09-25 Thread kcvinu
Assume that i have a proc like this proc myProc( a : auto) = #need to check what the type of a, I am expecting an int, float, string. # do some operations Run How can i check the type of a ?