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".}
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.
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
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))
Thank you! That sounds the official nightlies is better. Wandbox has simple
test that just compile tiny test code and check output.
Test code:
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
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?
=>
[https://gist.github.com/rayman22201/92f28f0c1d9ccbc5a36fe04c2132c49e#gistcomment-2811762](https://gist.github.com/rayman22201/92f28f0c1d9ccbc5a36fe04c2132c49e#gistcomment-2811762)
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)
can u show a minimal reproducing example?
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
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.
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
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
No, just like you cannot "undefine" a function in C.
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`.
It's a good idea for visibility but I find stack overflow moderation quite
toxic though.
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
**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)
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
according to style guide, types should have uppercase first letter, and proc -
lowercase. thats enough to resolve this naming conflict.
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
So, change the whole language so you can copy-paste some FreeBasic stuff?
The code reordering experimental someday can improve this (?).
Is there anyway to undefine a symbol in nim using macros? like in C you can do
#define SYMBOL_NAME
#undefine SYMBOL_NAME
Run
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)
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
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
I need a typed symbol.
Thank you. :)
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.
30 matches
Mail list logo