proc addInt(a,b:int):int {.asmNoStackFrame.} =
asm """
mov eax, `a`
add eax, `b`
ret
"""
echo addInt(3,4)
Run
The above results run to 0.,I hope someone can help me. thanks
With 0.19.4 we now ship the nightly builds which introduced new problems.
Working on a fix.
As a newbie coming into Nim just this very week (with extensive background in
C++, Go, & many more):
* I found the "Nim by Example" \+ the manual surprisingly approachable, easy
to read and generally "good enough"; also, using the manual as a
reference/searching is acceptable (it's good that
@akavel \- you may (or may not) have noticed the "Group By Type" drop-down menu
on the doc page for any given module (e.g. clicking on `tables` from
`theindex`). That's sort of like what you're asking for.
The big `theindex.html` doesn't have that Group By feature, but perhaps should.
The optio
Look at the assembler code:
@addInt_WYbpHhMOLfd0wzp13vORMw@8 PROC NEAR
mov eax, dword ptr [ebp-4H] ; 0020 _ 8B. 45, FC
add eax, dword ptr [ebp-8H] ; 0023 _ 03. 45, F8
ret
Add the pragma `.cdecl.` or `.stdcall.` to addInt doesn't change the type nim
compiler treat the parameter of addInt, maybe this is the bug.
It's true that the implementation relies on the knowledge of the GC internals.
Afaik, all nim GCs should be fine with it. And likely, it's gonna stay that way
for the foreseeable future, but no warranties from me :).
As to "index" \- sorry, I used bad term here, I now understand. I didn't mean
"theindex", I meant the "ToC" shown in the left-side pane on e.g.
[https://nim-lang.org/docs/system.html](https://nim-lang.org/docs/system.html)
\- the big list of links just below the "Group By" selection box. I tried
> Also, I do see type signatures
But in the module docs there is no type signature, for example in
[https://nim-lang.org/docs/tables.html#merge%2CCountTable%5BA%5D%2CCountTable%5BA%5D](https://nim-lang.org/docs/tables.html#merge%2CCountTable%5BA%5D%2CCountTable%5BA%5D)
there is proc getOrDefault
I recently held a lightning talk at FOSDEM and the video from that got uploaded
today. If you didn't have the possibility to attend FOSDEM you can watch it
here:
[https://peterme.net/meta-programming-in-nim-fosdem-talk-companion-post.html](https://peterme.net/meta-programming-in-nim-fosdem-talk-
Doesn't `asmNoStackFrame` mean that you're on your own completely, even getting
the calling convention right? Which defaults to `fastcall` on win32 though.
Should I submit a PR to capture what you, @Araq, just said in some appropriate
way in the typeinfo documentation?
Sure thing, thanks!
As I write my own code, I feel as though I'd want to either avoid this (perhaps
instead using the approach I showed at the opening of this thread) or PR a
documentation change that blesses it. Thoughts on which is better?
If the `asmNoStackFrame` disable any call convention pragma, a warning is
required when it is combined with call convention pragma or the code refer the
parameter name.
But I think maybe we can specify calling convention, so the following code may
correct:
asm """
mov eax, `a`
"""
Run
Otherwise, we cannot refer the parameter in the assembler code. But it still
make sense, because the vcc compiler treat the __declspec(naked
Your presentation skill is great! Your speech was calm, relaxed and clear.
Minor comment: Can you repeat/summarize the questions from the audience next
time (yes, I am looking for more of your talks :))? The actual questions are
never audible in such conferences.
Thanks!
I like it very much, your calm way of presenting Nim is very nice. Minor
nitpick: "as flexible as Perl" wasn't my goal. :D
Sure but maybe don't use pragmas you don't understand. `asmNoStackFrame`
screams "I know what I'm doing" to me.
The real question is here why you need --os:standalone. What
feature/implementation detail of system.nim prevents you from using it in its
standard setting?
Is that with Nim devel? I just pushed something to mitigate this issue.
Thanks a lot, but damn I was sure I heard you say that at some point!
Thanks, and yeah we talked about that before the talk but my mind completely
blanked on that when I was on stage.. I chose the mixed audio source though, so
it should've included just about enough of the audio to make out the questions.
Maybe I should transcribe them under the video though.. And
Well, I started with os:standalone because Ultibo does not have a linux api so
I can’t use os:linux nor any of the other choices. Perhaps what I don’t know is
how to link a memory-only (no os calls) nim program to ultibo. What would be
easiest would be for the nim entry point to receive a large
@akavel \- you're welcome.
@both \- I'd have to agree that in a language like Nim which relies heavily on
type-based overloads that long lists of the same ident in that side-bar/ToC
section is not helpful. Right now each is a hyperlink to the specific one. So,
collapsing would remove that choic
Cool! No, not devel; I'm a total newbie to Nim, so I just downloaded 0.19.4 on
Windows this week and am trying to use it. Is there some approachable way I can
try using the mitigation and continue developing/porting my code (from Rust)?
> Is there some approachable way I can try using the mitigation
Many, maybe most people are using latest Nim devel, see
[https://github.com/nim-lang/Nim#compiling](https://github.com/nim-lang/Nim#compiling)
Cool, thanks a lot, I'll try it then!
I'm afraid there seems to be still the same issue :(
Not sure if it matters, but if the error message is correct, the difference
seems to be in the locks: 0 phrase, not in the ReadIOEffect etc. that were
changed in the recent commit. Or is it more complicated than I think?
I would like to have some thing like this override/section thingy bellow:
If I have just a section named "redbox" I just want it to act normally with no
substitution:
section "redbox":
echo "boring stuff"
Run
But if I have an override block, some where in the co
This essentially does what you want.
template override(a, b : untyped) : untyped =
template a() : untyped =
b
template section(a, b : untyped) : untyped =
when compiles(a()):
a()
else:
b
override redbox:
echo "this is
import asyncdispatch, asyncnet
template asyncDo(x) = asyncCheck (proc {.async.} = x)()
let s = newAsyncSocket()
s.setSockOpt(OptReuseAddr, true)
s.bindAddr Port 12345
s.listen
let c1, c2 = newAsyncSocket()
for c in [c1, c2]:
asyncCheck c.connect
I thought of another way to solve that doesn't produce side effect templates.
import macros
import tables
var overrides {.compiletime.} = initTable[string,string]()
macro override(a, b: untyped) : untyped =
var x = genSym(nskTemplate)
overrides[a.strVal]
this iterator does not works
items*[T](a: var Vector[T]):var T =
for i in 0..a.size:
yield a[i]
Run
when I writing this
loadedmesh in this.objdata.LoadedMeshes:
Run
where this.objdata.LoadedMeshes is vector, that uses my iterator. co
Wow this is great. I really like the two approaches you made. Thank you!
>From Araq's blog — [Nim and Perl](https://nim-lang.org/araq/perlish.html) —
> Last month I tried to reimplement Perl in Nim and to see how well Nim's macro
> system holds up for unusual domain specific language requests. **Personally I
> do not like Perl at all** , but for a language designer i
I'm all for Nim support in Geany, but focusing on [the most popular
IDEs](http://pypl.github.io/IDE.html) first would be most beneficial... Support
in IntelliJ and Visual Studio (Proprietary, not Code) is lacking...
Nice, for the amount of time you had it was a good taste of what nim can do.
Not really how to do it but it should get people interested in that
> `for i in 0..a.size:`
Just a basic remark, and others, who are more experienced with C++, can help
you with the rest: `..` is inclusive range, here you need to use `..<`.
39 matches
Mail list logo