Re: the ignoring of _ make some translation need more work

2019-01-16 Thread moerm
The following _does_ work: // file ccall.c int some_weirdly_named_func(int p) { return(p += 10); } Run # file ccaller.nim {.compile:"ccall.c".} proc weirdCcall(p: cint) : cint {.importc:"some_weirdly_named_func".}

Re: generic instantiation with object inheritance

2019-01-16 Thread mratsim
Depending on what you want to optimize (size or speed), you might want to stay with your initial version. The cache misses from dereferencing the extra node payload will be very costly.

Re: generic instantiation with object inheritance

2019-01-16 Thread rayman22201
You would check which type it is using the of operator if curr of BBNode2: #cast to a BBNode2 else if curr of BBLeaf: #cast to a BBLeaf Run

Re: How to get the address of an proc with same name and different parameter type

2019-01-16 Thread slangmgh
Find a way, the following code seems fine. proc p2(x: int) = echo x proc p2(x: string) = echo x let t1: proc(x: int) {.nimcall.} = p2 let t2: proc(x: string) {.nimcall.} = p2 t1(10) t2("string") echo toHex(cast[int](t1))

Re: Nim nightly builds

2019-01-16 Thread demotomohiro
Thank you! That sounds the official nightlies is better. Wandbox has simple test that just compile tiny test code and check output. Test code:

How to get the address of an proc with same name and different parameter type

2019-01-16 Thread slangmgh
When two proc have the same name, how can I get the proc address? proc p2(x: int) = echo x proc p2(x: string) = echo x let t1 = p2 # Run

Re: generic instantiation with object inheritance

2019-01-16 Thread e
Casting to any of the subtypes of BBTree isn't safe because in the iteration of inorder the type of curr can be BBLeaf or BBNode2... isn't that the point of inheritance from a supertype?

Re: generic instantiation with object inheritance

2019-01-16 Thread timothee
=> [https://gist.github.com/rayman22201/92f28f0c1d9ccbc5a36fe04c2132c49e#gistcomment-2811762](https://gist.github.com/rayman22201/92f28f0c1d9ccbc5a36fe04c2132c49e#gistcomment-2811762)

Re: generic instantiation with object inheritance

2019-01-16 Thread rayman22201
Let me help, because I'm also interested in the answer to this: This should be a more minimal reproduction: [https://gist.github.com/rayman22201/92f28f0c1d9ccbc5a36fe04c2132c49e](https://gist.github.com/rayman22201/92f28f0c1d9ccbc5a36fe04c2132c49e)

Re: generic instantiation with object inheritance

2019-01-16 Thread timothee
can u show a minimal reproducing example?

Re: Nim nightly builds

2019-01-16 Thread shashlick
Nice work, especially offering devel right there with multiple releases as well. So the advantage of the official nightlies is that it is tested and posted only when it passes all testing. With #head, you could sometimes download a broken build depending on your timing. However, only the

Re: Nim nightly builds

2019-01-16 Thread demotomohiro
Nightly build Nim compiler is available in this online compiler: [https://wandbox.org](https://wandbox.org)/ Select nim language and nim HEAD to use nightly build. I wrote a blog post about Wandbox for Nim users.

generic instantiation with object inheritance

2019-01-16 Thread e
My persistent bounded balance tree library is working well. Now I want to optimize. The tree type is type BBTree*[K,V] = ref object of RootObj # BBTree is a generic type with keys and values of types K, V ## `BBTree` is an opaque immutable type. key: K

Re: Using Stack Overflow for help

2019-01-16 Thread dom96
Sorry but I disagree with this approach. I don't think we should be optimizing for a metric that somebody made up for programming language popularity. How would this even work? Would we ban users for posting questions on our forum and tell them to use SO? I don't think that would make anyone

Re: ability to undefine a symbol?

2019-01-16 Thread Araq
No, just like you cannot "undefine" a function in C.

Re: the ignoring of _ make some translation need more work

2019-01-16 Thread Araq
Wrapping is always some effort, especially if you want the result to read like Nim code. * You need to figure out if `T*` means "pointer to T" or "pointer to an array of T". * You need to figure out how to translate `#define`. * You need to figure out if `char` means `byte` or `char`.

Re: Using Stack Overflow for help

2019-01-16 Thread mratsim
It's a good idea for visibility but I find stack overflow moderation quite toxic though.

Using Stack Overflow for help

2019-01-16 Thread shashlick
As much as I like our forum, I think it is worth asking whether how-to questions around Nim should go on Stack Overflow instead given how SO activity is used as a metric of how active a project is. We get a slow [trickle](https://stackoverflow.com/questions/tagged/nim) of questions on SO but

Re: Arraymancer - v0.4.0 (May 2018)

2019-01-16 Thread juancarlospaco
**Intro to Tensors** [https://github.com/juancarlospaco/nim-presentation-slides/tree/master/ejemplos/avanzado/tensorflow#intro-to-tensors](https://github.com/juancarlospaco/nim-presentation-slides/tree/master/ejemplos/avanzado/tensorflow#intro-to-tensors)

Re: Arraymancer - v0.4.0 (May 2018)

2019-01-16 Thread mratsim
There is a [memowner bool in the type](https://github.com/numforge/laser/blob/990e59fffe50779cdef33aa0b8f22da19e1eb328/laser/tensor/datatypes.nim#L12-L30). If it's false, it will not deallocate memory when not referenced. const LASER_MAXRANK*{.intdefine.} = 6 type

Re: the ignoring of _ make some translation need more work

2019-01-16 Thread SolitudeSF
according to style guide, types should have uppercase first letter, and proc - lowercase. thats enough to resolve this naming conflict.

the ignoring of _ make some translation need more work

2019-01-16 Thread oyster
for example, in FLTK C for FreeBasic, there is (faked) enum FL_TEXT_DISPLAY_WRAP_MODE, i.e. type FL_TEXT_DISPLAY_WRAP_MODE as ulong Run which is used in funtions like declare sub Fl_Text_DisplayWrapMode(byval td as Fl_Text_Display ptr, byval wrap

Re: the ignoring of _ make some translation need more work

2019-01-16 Thread miran
So, change the whole language so you can copy-paste some FreeBasic stuff?

Re: Global procedure access?

2019-01-16 Thread juancarlospaco
The code reordering experimental someday can improve this (?).

ability to undefine a symbol?

2019-01-16 Thread lotzz
Is there anyway to undefine a symbol in nim using macros? like in C you can do #define SYMBOL_NAME #undefine SYMBOL_NAME Run

Re: Global procedure access?

2019-01-16 Thread miran
proc b() proc a(n: int) = b() proc b() = a(42) Run Forward declaration needed, [see here for a short example/explanation](https://narimiran.github.io/nim-basics/#_forward_declaration)

Global procedure access?

2019-01-16 Thread lqdev
I don't know if I titled my problem correctly, but this is what I'm trying to achieve: proc a(n: int) = b() proc b() = a(42) Run I know this example would recur infinitely, but my actual use case breaks `a` on a condition. I already tried using

Re: "Nim needs better documentation" - share your thoughts

2019-01-16 Thread miran
Nim now has better documentation for four most used modules: `strutils`, `sequtils`, `tables`, `math`. See some [before and after screenshots](https://imgur.com/a/7pRwzfr). * * * But that is only a start, there is a lot of work remaining to be done, and we're hoping for some help from our

Re: Is it possible get the export flag of a type symbol

2019-01-16 Thread slangmgh
I need a typed symbol. Thank you. :)

Re: Is it possible get the export flag of a type symbol

2019-01-16 Thread Araq
You can check for the export marker in the AST if you instead accept an `untyped` parameter. There is no `macros.isExportedSymbol`. PRs are welcome.