I'd love an Option[T] without overhead, was just looking for this.
I'll just use "nil" for now but that would be better.
Nim doesn't expose that to the end user. The official docs for Nim locks say
that whether a lock is re-entrant or not is "unspecified", so where are you
seeing this?
@See:
[https://nim-lang.org/docs/locks.html#Lock](https://nim-lang.org/docs/locks.html#Lock)
A re-entrant lock is a lock that
Hi all!
First post... After waiting about nine months for Nim in Action to finally be
delivered to me, I got it 3 days ago. In the 3rd chapter, I should start to
code. So I decided the first thing to do was obviously to install some Nim
editor (I'm on Win10 x64). Now, after two whole evening,
> It seems to me it means something is wrong with Nim's symbol lookup. Or am I
> missing something?
I failed to guess what example you used to produce this error. This compiles:
template someCode(name: untyped): untyped =
type name {.inject.} = object
fname: string
@boia01: If a faster hash function is used, your code is one third faster than
python.
For those who want to try: clone
[xxHash](https://github.com/Cyan4973/xxHash.git) right next to the Nim source
file and insert this below the _import_ statement:
import hashes
const
Well, you have no choice than use macros. If you don't want to deal with the
ast, you can still [work with strings](https://glot.io/snippets/eu2z63ru1r):
import macros, strutils
macro typeGen(tName, extra: untyped): untyped =
var typeStr = """
type
The above code was just an example. In general I would like to be able to paste
code using templates or macros in a similar way that you can with D's string
mixins which allow you to generate strings using functions and then paste them
anywhere and generate code in compile time. In the above
`with` is a keyword, so you can't use that. You could use something like this
maybe?
import macros
macro take(args,body:untyped):untyped =
result = newstmtlist()
result.add(newvarstmt(args[^1],args[1]))
for st in body: result.add(st)
take 3 as f:
Thanks for the replies
Is it possible to express the "withAs" template as a macro?
So that my example could look like this:
with open("test.txt") as f:
echo f.readLine()
I think it should be possible, since eg nimpylib lets you use this syntax:
class
It's from 1999.
It would probably be better to work directly with a current Nim native library
like Design by contract
[https://forum.nim-lang.org/t/2479](https://forum.nim-lang.org/t/2479).
Also I'd rather have those graduate students develop actual libraries (with
unit tests). I don't think
I looked at two libs docs and found it's same between those two.
What's the different between those?
11 matches
Mail list logo