import sets
var h: HashSet[string]
proc main =
h.incl("Nim")
let b = h
h.incl("VLang")
h = b
echo h.contains("VLang")
main()
Run
The output is true.
But with "var b" it would be false. So it seems that "let b = h" creates just
I think you are confuse nim templates with template from another language. I
actually didn't not expect options to be available inside dsl, for that you
have to use a macro.
There is some problem with my nim.cfg, I replace the nim.cfg to the original
one, it is fine now. I will check my nim.cfg to see what is the culprit.
Can you please share your version of Nim and Nimble?
When I run `nimble install jester`, it gives following error message:
Downloading https://github.com/dom96/jester using git
Tip: 3 messages have been suppressed, use --verbose to show them.
Error: Could not read package info file in
D:\Tmp\Temp\nimble_\githubc
For future use in case someone needs it, here is a bit of feedback from my
experiments.
1. Keep in mind that template is only **code rewriting**.
2. Keep templates for **simple** rewriting rules.
3. Don't use imbricated templates to manage scoping rules!
4. Use `block:` to manage scopes (
Hello when I forward to a proc in the example fldX.name
I wanted to remove the error
Hint: passing 'fldP.name' to a sink parameter introduces an implicit copy;
use 'move (fldP.name)' to prevent it [Performance]
So I used "move", but actually I lost the value and the variable. moreover we
se
Here is a better example, not involving subranges. Maybe Nim is working as
intended, but as a new user of Nim, it seems strange.
# this is a nim test program
import tables
var
map = initTable[int, int]()
const print = echo
let
ani = 0
Let's summarize things:
* **UTF-16** works for input in Windows console, **UTF-8** does not.
* We must use a **" W"** function in order to get correct input from the
Windows console. This function uses **UTF-16** and does not actually depend on
**SetConsoleCP**.
* **SetConsoleCP(65001)**
off-topic: but what VSCode theme is that?
I found this froum thread helpful
[https://forum.nim-lang.org/t/3898](https://forum.nim-lang.org/t/3898)
> It's not a hack, I don't know where it is documented, but
This openarray usage with C bindings would be useful for the API I’m working
with; but I’d need to see it documented. If it’s not documented then it’s just
a side effect of the implementation, which could change at any time.
I suppose
> It's unstructured control flow and our competitors don't support it either.
Hm. Are you implying this is poor structure or non-idiomatic? Is it the lack of
`else:` block you object to?
While I’m not sure whom you count as “competitors”, Clang does do that type of
analysis. The control-flow an
Either you use destructors, or you use ref with finalizers
Pseudo code
Destructors version
type NimBox = object
handle: ptr Box
proc `=`(dst: var NimBox, src: NimBox){.error: "Copying is not allowed".}
proc `=destroy`(b: var NimBox) {.inline.}=
relea
It's not a hack I don't know where it is documented but for this code:
proc setDash*(cr: Context, dashes: openarray[float64], offset: float64)
{.importc: "cairo_set_dash".}
var
dashes = @[
50.0, # ink
10.0, # skip
10.0, # ink
10.0 # skip
Like I said, my goal is to write safe code and not rely on internal hacks.
Optimizations are not my concern, for the moment, as I delegate them to
improvements to the Nim compiler.
Solution #1 relies on knowledge of `seq[]` internals, and even if it's widely
used, I'm reluctant to using it in m
If its a ptr[T], len pair you can wrap the C function with openarray[T], don't
know what happens when its `len, ptr[T]` though
According to the
[destructors](https://nim-lang.org/docs/destructors.html#sink-parameters)
document , you don't have to use move since each object field may be sinked
separately. The compiler also infers when it is safe to sink, look at section
Rewrite rules.
You can watch [Nim move semantics]
Well `move` can be a dangerous operation so you should use it when you're 100%
sure that your code won't use the variable you `move`'d afterwards. This code
will output an empty string because there was a `move` on `fldX.name` and it's
now empty:
type
Vtest = ref object
Number 1 is widely used, you can even use `unsafeAddr` if nothing is going to
be written to and you need to use a `let` array
Nice work!
You would probably want to make nNumberOfCharsToRead a uint32 for consistency.
Also test for "rn" (maybe also for plain "n"?) at the end of the string,
because they may just not be there if the typed string is larger than readBuff.
Now only selecting a suitable console font is necess
21 matches
Mail list logo