GetType() for object type macro parameter

2017-08-28 Thread Stefan_Salewski
import macros type S = string I = int O = object i: int P = ref O var i: I var s: S var p: P var o: O macro mconnect(arg: typed): typed = let at = getType(arg) echo $(at.toStrLit) if at.len > 1:

Re: Export docs? Submodules?

2017-08-28 Thread Udiknedormin
More precisely: for exported entities. Meaning: # foo.nim const sth* = 5 const oth = 4 # bar.nim from foo import sth export sth bar.nim docs should include sth but not oth. Also, it should be explicitly marked as exported in the docs unless foo.nim is

Re: optional int parameters for a proc

2017-08-28 Thread Udiknedormin
Overloading has one major disadvantage: proc hasTwoIntArgs(x = 3, y = 4) = ... hasTwoIntArgs(x = -1) # args: x = -1, y = 4 hasTwoIntArgs(y = -1) # args: x = 3, y = -1 proc hasTwoIntArgsInvalid(x, y) = ... proc hasTwoIntArgsInvalid(x) =

Re: Question regarding the setter method/proc

2017-08-28 Thread Udiknedormin
It seems to me it would be better to not allow a getter/setter to be named just like a private field. It's quite misleading.

Re: Defining an array inside a tuple

2017-08-28 Thread Udiknedormin
Wow! I'm really lucky as far as finding bizzare language subtelties or compiler bugs but... I've actually encountered this behaviour before. I guess I just assumed you can use constructor syntax with any type. @rayman22201 array is pretty much std::array and seq is pretty much std::vector. I

Re: Nim - nimble, nake, confused

2017-08-28 Thread jacmoe
> That is precisely what's happening Excellent! I'll carry on with Nimble, then

Re: Nim - nimble, nake, confused

2017-08-28 Thread dom96
> and it looks like that Nimble is slowly obsoleting Nake by incorporating most > (all?) of Nake's features That is precisely what's happening You should be able to use Nimble for most use cases nowadays.

Re: Defining an array inside a tuple

2017-08-28 Thread rayman22201
Thank you for your help everyone. @BigEpsilon: I understand the difference seq vs array. An array is a fixed size from compile time (a C array with the size information stored in the type system), and a seq is closer to a std::vector in C++. My question is about setting the default values of

Re: Nim - nimble, nake, confused

2017-08-28 Thread jacmoe
Thanks, Andrea, for confirming my thinking. To me, it makes a lot of sense to let a package manager handle builds, versions and dependencies, and it looks like that Nimble is slowly obsoleting Nake by incorporating most (all?) of Nake's features. At the very least it can explain the overlap

Re: Nim - nimble, nake, confused

2017-08-28 Thread andrea
Notice that nimble now supports tasks, which are custom command, scriptable with nimscript. This should be extensible enough to cover your needs. Nake is a build tool - I have never used it, since I find that build tools need to be coupled to a package manager to be useful - there is no way to

Re: Nim - nimble, nake, confused

2017-08-28 Thread jacmoe
> will compile not only your_program.nim, but also all imported modules > recursively and build the final complete executable, so most of time you need > just the compiler to build your project. That is true, and also how I started out - mainly due to the fact that the Nim tutorial does not

Re: Been away for 9 months. What changed? Need some help to get back on track.

2017-08-28 Thread jlp765
Yeah, I guess I assumed a blog was stories rather than news announcements. Other (younger) people probably would not have made that assumption.

Re: Question regarding the setter method/proc

2017-08-28 Thread pgmf
Thanks again @Lando for confirming this. It more clear to me now. Best Regards

Re: Bug with generic methods?

2017-08-28 Thread def
That's obviously supposed to work and it's a bug when using methods in combination with generics. Without generics it works fine: type Console* = ref object of RootObj ViewportConsole* = ref object of Console method draw*(self: Console, engine: string) =

Re: Bug with generic methods?

2017-08-28 Thread Lando
Probably an [object variant](https://nim-lang.org/docs/manual.html#types-object-variants). Or maybe wait until concepts are implemented.

Re: Bug with generic methods?

2017-08-28 Thread Lando
That's because of the sequence. If you would store the objects in two separate sequences for _Console_ and _ViewportConsole_ instead, you would get the expected result. Apparently, _var consoles: seq[Console]_ sets the runtime type of the elements to **exactly** _Console_.

Re: Question regarding the setter method/proc

2017-08-28 Thread Lando
Correct. This is why the name of the field was changed to something other than _host_ in the updated example code.

Re: Defining an array inside a tuple

2017-08-28 Thread Krux02
I think you should use `object`, it is the equivalent of `struct` from C. type Vec2i = object x,y: int Vec2f = object x,y: float NVGglyphPosition = int32 GlyphArray* = array[100, NVGglyphPosition] TextBuffer* = object

Re: Question regarding the setter method/proc

2017-08-28 Thread pgmf
@Lando, Many thanks for your reply, much appreciated. I was really confused. This is how I understand the concept from your reply. Please correct me if I am wrong. * if ' s.host = 34 ' is called from the _same module_, it will directly access the object variable bypassing the 's.host='

Re: Been away for 9 months. What changed? Need some help to get back on track.

2017-08-28 Thread Araq
> You access them from the blog: > [https://nim-lang.org/blog.html](https://nim-lang.org/blog.html). Why isn't > this obvious? Because it should be named "news" instead?

Re: Question regarding the setter method/proc

2017-08-28 Thread Lando
The example from the tutorial is a bit misleading, try the updated [version from the language manual](https://nim-lang.org/docs/manual.html#procedures-properties) instead. The _host_ field of a _Socket_ object is invisible to code from a different module, but the tutorial example code accesses

Re: Nim - nimble, nake, confused

2017-08-28 Thread LeuGim
> my needs are simple Consider first in Nim running just `nim c your_program` will compile not only _your_program.nim_, but also all imported modules recursively and build the final complete executable, so most of time you need just the compiler to build your project.

Re: Question regarding the setter method/proc

2017-08-28 Thread pgmf
Aplologies, there was an error in my program, corrected now. My question still stands though. Thanks.

Re: Nim - nimble, nake, confused

2017-08-28 Thread jacmoe
The reason I am confused is because if nimble is able to handle builds (nimble build) I would rather not have to deal with nake, if I can help it. Nake is probably more fully featured, but my needs are simple. Since I am totally new to Nim, I thought I'd ask you guys for advice. Are you using

Re: Defining an array inside a tuple

2017-08-28 Thread LeuGim
In addition to what _BigEpsilon_ says, if you want to instantiate it that way, you may use a template for not creating an additional variable explicitly each time and to fit all in one initialization: template ofType(typ: typedesc): auto = var x: typ x # usage

Nim - nimble, nake, confused

2017-08-28 Thread jacmoe
I am a bit confused about the difference between nake and nimble when it applies to project management. Coming from Rust, where I am used to use Cargo to manage my projects/builds. I am currently using 'nimble init' to kick off a new Nim project, but I am aware of nake, which is a build tool.

Re: Defining an array inside a tuple

2017-08-28 Thread BigEpsilon
You don't need to instentiate an array because it is already instentiated. Try this Var x :TextBuffer echo repr (x.glyphPositions) Which should print 100 element with the default value of NVGglyphPosition, and that because array[100, X] is a fixed size array, wich means

Defining an array inside a tuple

2017-08-28 Thread rayman22201
I am a Nim n00b, and one of the hardest things I am having trouble with is dealing with arrays in Nim. I have the following typedef type GlyphArray* = array[100, NVGglyphPosition] type TextBuffer* = tuple position: tuple[ x : float, y : float ]

Re: Simple Python-like class macro and some python-like procedures (print, input, range, others)

2017-08-28 Thread Krux02
@dom96 I am fairly sure that I submitted a pull request (that got accepted) not that long age that fixed the doc comments.

Question regarding the setter method/proc

2017-08-28 Thread pgmf
Hello all, A newbie here. I have been learning Nim using the online tutorials and is thoroughly enjoying Nim . I have completed the part 1 and have advanced to Part 2 of the tutorial. Have a question regarding the setter methods discussed in the 'Properties' section of the tutorial. Can you