It was my preferred way of getting value out of **emit** body to nim side. That 
was working with global variables for me and using it in local scope seemed not 
against the rules of the Manual.

Now with your help i know how it works in reality, so I must use another way 
(declare variable before the **emit** and pass it inside with help of 
emit-array notation, though i think it's a bit ugly to use all that 
square-brackets/commas/quotes(single or triple)).

it is more simplier to just write something like:

  1. emit: "... int i; ..."
  2. then tell Nim that i want to use that "i" variable outside emit scope (on 
nim side) by declaring it afterwards with **nodecl,importc** pragma.



so Nim will not declare it but will assume that it was already declared 
somewhere above. It will allow to write simpler and clearer code.

I'm not asking to implement it. :-) I understand that using **emit** pragma is 
already very ugly by itself. I just think that the Manual is not clear enough 
on how to use **decl** pragma with variables correctly. for me it was just a 
simple logic - "nodecl" always means "no declaration", in other words "tell nim 
to assume that variable was already declared"

Reply via email to