I really think you should use objects for this, but this will work anyway:
import tables
var books = newTable[string, TableRef[string, string]]()
books["one"] = newTable[string, string]()
books["one"]["price"] = "150"
echo books["one"]["price"]
What about Godot? It also has Nim bindings and Godot generally has a pretty
good 3D support already.
I just wanted to have logging which has colors, and also have chronicles-style
printing of arguments, so I created this relatively small snippet for logging:
[https://gist.github.com/Yardanico/0bcf50c05b71ae8990529ea0913ac068](https://gist.github.com/Yardanico/0bcf50c05b71ae8990529ea0913ac068)
I just wanted to have logging which has colors, and also have chronicles-style
printing of arguments, so I created this relatively small snippet for logging:
[https://gist.github.com/Yardanico/5e2c012b184d45c4a845f820927cc2e1](https://gist.github.com/Yardanico/5e2c012b184d45c4a845f820927cc2e1)
Since Unicode contains all ASCII characters you can easily do that:
import unicode
let my_rune = Rune(ord('.'))
echo my_rune
Run
@mratsim Why does Nim need warm-up? I've never heard about that.
You should do "import oldwinapi/windows", not "import windows".
They are checked at runtime, but not in release mode (because -d:release does
--rangeChecks:off)
TS probably means "processor threads" \- Hyper Threading
Please report it on github!
jackmott: I really think you should use templates instead of inlined procs
here, because it's not guaranteed that proc will be inlined (even with inline
pragma)
I've created a new Discord Nim channel:
[https://discord.gg/ezDFDw2](https://discord.gg/ezDFDw2)
The recording is now available!
[https://www.youtube.com/watch?v=KNUDGZuqfQM](https://www.youtube.com/watch?v=KNUDGZuqfQM)
[http://www.strawpoll.me/14163114](http://www.strawpoll.me/14163114) Vote for
your favourite topic!
Araq will be streaming on Thursday, 19:00 UTC!
Yes, not using object of meant you were "pure"
About toString - in Nim $ is used as a stringify operator for almost all types
anywhere (not only in stdlib). So firstly try $ on a type
c2nim already supports C++ templates
cdunn2001: "There's actually a lot of places I'd really like to use "withAs"
in, eg to make sure that resources are closed, but without needing to add a
resource-specific "defer" line." So wizzardx will need to create a template
like this for every type he'll use
wizzardx: yes, and nim uses niminst
coffeepot: I'm afraid it isn't possible to implement it using a variable (e.g.
something like $line). Yeah, it is possible to add this just as template, but I
don't really think it would be accepted in stdlib
Nim allows getting a line number from a template (via compile-time
information). So you can make a log template to do that:
import logging, strutils
var logger = newConsoleLogger(fmtStr = "[$time][$levelid]")
addHandler(logger)
template log*(lvl: Level, data:
monster: you wouldn't get only "syntax highlighting" with VSCode. Nim plugin
also supports "nim check" \- checking files for errors, and nimsuggest - code
completion (it knows everything about Nim)
[https://gist.github.com/stisa/09474a952a420448778685507d3fbd51](https://gist.github.com/stisa/09474a952a420448778685507d3fbd51)
well, no, only "with" and "without":
[https://github.com/nim-lang/Nim/commit/3ccc9c467d84dc8c3412acbea20fc10b5335eaa8](https://github.com/nim-lang/Nim/commit/3ccc9c467d84dc8c3412acbea20fc10b5335eaa8)
Udiknedormin: you can change "take" to "with", since "with" and "without" were
removed from Nim keyword list in devel
It's very easy with "quote do":
import macros
proc my_enter(x: int): int =
echo "my_enter was called"
return x
proc my_exit(x: int) =
echo "my_exit was called"
macro take(args, body: untyped): untyped =
# Value of an argument
You can use defer for closing resources:
[https://nim-lang.org/docs/manual.html#exception-handling-defer-statement](https://nim-lang.org/docs/manual.html#exception-handling-defer-statement)
LeuGim: a side note: it's not an implicit conversion, with "var x: int8" Nim
treats your "3" literal as "int8" type
sflennik: your code is wrong, OrderedTable can't contain different types It
should be like this:
from tables import OrderedTable, toOrderedTable
proc getMetaInfo(filename: string, fileSize: int64): OrderedTable[string,
string] =
result = {
"filename":
[https://github.com/Yardanico/nim-mathexpr](https://github.com/Yardanico/nim-mathexpr)
This is a mathematic expression evaluator library in pure Nim (with no
third-party dependencies).
Basically it is a recursive descent evaluator.
It supports many mathematical functions, also you can provide
Well you would wrap this functions too? And I really think you should make it a
real wrapper
Udiknedormin: can you post a code example? And also create an issue on github
@alexsad - don't try to compare JS code compiled by Nim with hand-written JS.
It's almost the same if you compare hand-written C++ with C++ code compiled by
Nim
cdome: but one problem - vtrefs are not implemented yet
[https://github.com/Yardanico/nimpylib](https://github.com/Yardanico/nimpylib)
Yes, Stefan_Salewski is right:
type
NodeKind = enum # the different node types
nkInt, # a leaf with an integer value
nkFloat# a leaf with a float value
# Version 1 with object variant
Node = ref NodeObj
NodeObj
Try to add gcsafe pragma to your proc
You can also try concepts
But you shouldn't write export PATH... in terminal you should write it in your
.bashrc or .zshrc or .rc
My macro:
import macros
macro createObj(typ: typedesc, data: untyped): untyped =
# This macro only accepts tuples in parenthesis, but this can be changed
assert data.kind == nnkPar
# Object construction syntax
result = newTree(nnkObjConstr)
#
You can definitely do this with a macro
Maybe you can't access Nim directory from user account because it has wrong
permissions? And also maybe you have another Nim installed?
Udiknedormin: yeah, or maybe IRC
Udiknedormin, I've added lazy evaluation for range -
[https://github.com/Yardanico/nimpylib/blob/master/src/pylib/range.nim](https://github.com/Yardanico/nimpylib/blob/master/src/pylib/range.nim)
I've even changed -fno-strict-aliasing to "-fstrict-aliasing -Wstrict-aliasing"
in build.sh (in csources), and nim compiler compiled without any issues!
It seems that Julia JIT is aware of SSE extensions and it uses them. GCC or
MSVC should be emitting them too, but it depends on C code
If you don't want the music, just turn it off History from 2008 to 2017
[https://www.youtube.com/watch?v=rUJ7Bzgv3n0](https://www.youtube.com/watch?v=rUJ7Bzgv3n0)
DTxplorer: don't worry, nothing bad
DTxplorer, you need to install godot-nim package itself first
You can now use Godot-Nim with master branch of Godot (so newest version)
Author said that only one PR to godot engine left
>From the example:
# Copyright 2017 Xored Software, Inc.
import strutils
import godot
import engine, label, resource_loader, packed_scene
gdobj FPSCounter of Label:
var lastFPS: float32
method ready*() =
setProcess(true)
[https://github.com/pragmagic/godot-nim](https://github.com/pragmagic/godot-nim)
Yay, proper GDNative bindings!!!
There's a simpler way to change the codepage
import os
discard execShellCmd("chcp 936")
Hi everyone! repl.it started a vote poll called "Language requests". Since
repl.it already supports C and C++, I think it would be not hard for them to
add Nim support.
Vote [here!](https://replit.canny.io/languages-requests/p/nim)
55 matches
Mail list logo