Have you seen [this thread](https://forum.nim-lang.org/t/2482)?
>From what you're writing, it is hard to understand what you want to do.
Okay, that worked. Should have tried beforehand, but I though removing all
`nimcache` dirs should be sufficient.
'/Users/flyx/Projects/3rdParty/Nim/config/nim.cfg'
[Conf]
Hint: used config file '/Users/flyx/Projects/3rdParty/Nim/koch.nim.cfg'
[Conf]
Hint: system [Processing]
Hint: koch [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [
You have to give us some information to work with. For example, what C compiler
are you using? And what's the output of the `sh build.sh` command when building
from source? Since `bin/nim` doesn't exist afterwards, this is probably the
problem, and the output most probably gives you the reason w
Shouldn't it suffice to make `e` `untyped`?
… because it is mentioned in the [system module's
documentation](https://nim-lang.org/docs/system.html#compiles,expr).
Your code does not work because you are using `func` as identifier, which is a
reserved keyword. I demangled it a bit and renamed `func` to `fun`:
type
MyProc1 = proc()
MyProc2 = proc(p: MyProc1)
MyProc3 = proc(p: MyProc1): MyProc1
proc applyAllSync(funcs:
Your JS is horrible to read as it lacks type information (what is funcs, what
is onAllDone, what is doBefore etc). I tried to interpret it but gave up. You
should rather explain what you want to do than giving us this piece of code.
Try:
proc pprint[T1](ann: string): (proc(t0: T1): T1) =
return proc(val: T1): T1 =
return val
echo pprint[int]("test")(42)
@hcorion This is Neo2 (it states that itself) and it is an image for printing
and gluing on the keys. Therefore, there are multiple meta-key images to choose
from.
> One key # is found only in UK and Ireland a far as I know.
Germany…
> Any keyboard, any standard, with numeric keypad, has + - * and /.
So moving your hand over to the numpad and back is faster than pressing two
keys?
> Just need people to think more open minded and understand that "this fea
> No attacks against anyone
You called people
> pythonic purists
which is obviously referring to people rather than the issue itself.
> I have no problems.
Your previous posts sounded differently.
> I want to help. Accept or deny.
Lacking commitment to discuss does not make your proposal loo
> 1\. Many keyboards does not have an one key access to "#", > as the "/" key,
> mine for instance, I usually need to look at alt-3 > or shift-3 combination.
Same is true for almost all other special characters which are used often in
Nim, e.g.: `(`, `)`, `:`, `=`. I do not see how `#` is differ
The macro will slurp `if debug: true else: false` as expression. It will not be
resolved; instead, inside the macro, you will have this whole expression in
your variable `debug`.
> Is there a way to 'extract' the boolean value of (the identifier) debug in
> the macro
It does not have a value w
By the way, you can check dependencies of your DLL with
dumpbin.exe /dependents libui.dll
(given that you have Visual Studio installed; it's in the VC bin folder)
> You may doubt that, but when run my Windows application alongside my "old"
> libui.dll, the GUI program runs fine.
That may be because it requires a version of MSVCP**.dll which is available on
your system. Or yes, because it has been statically linked into it.
> Do you know a good source whe
> But I have a version of libui.dll (linked above), which does not have this
> dependency and runs fine
I highly doubt it. The MSVCP140.dll is the C/C++ standard library on Windows,
and almost every C/C++ program depends on it. Typically, Windows has some
version(s) of this dll already preinsta
Well there are a lot of programs which just bundle MSVCP140.dll with their
executable, like you do with libui.dll. So why not just place MSVCP140.dll next
to it?
> It's also possible to directly install redistributable Visual C++ DLLs in the
> application local folder, which is the folder that
`debug` is an identifier and does not have a `boolVal`. You want to have
`dumbMacro true` instead of `dumbMacro debug`.
> complaining about a missing MSVCP140.dll
So why don't you just
[download](https://www.microsoft.com/en-gb/download/details.aspx?id=48145) and
install it?
For ensuring file closing:
var fh = open(filename)
defer close(fh) # close fh at the end of current block
process(fh)
Encoding is not part of the file opening process in Nim. A file is just read
byte for byte. If, for example, you want to open a latin-1 file and get a U
> but did not want to use inheritance and methods because it needs heap
> allocation
You are using strings so your objects are doing heap allocations anyway. You
should replace the strings with IDs of the target which got hit / died if you
don't want any heap allocation.
You can of course do s
With the same argument, it would also be necessary for Nim to have an official
package for debian, Fedora, Arch, Nix, Homebrew…
I think maintaining packages is in better hands with those people who use the
package managers.
There are no official rules. There have been threads about having a CoC and the
majority was against it. General opinion usually is _„instead of thinking about
rules, just write some Nim code“_. There also isn't some big sign on your front
door which tells you how to behave while out on the stre
> Regarding pointers being the only option for polymorphic returns; I guess
> this depends on the object layout used? For instance, I assume object variant
> does not need to be same size but still allows polymorphism in return value,
> simply by reserving space for the biggest variant in the ca
Generally speaking, whenever you are using `if v of SomeType`, you are holding
it wrong. Polymorphism gives you the power of defining dispatching methods for
operations whose implementation differs based on which subtype your variable
holds.
If implementing your code with dispatching methods se
References (or pointers) are a prerequisite for runtime polymorphism since they
are the only way to have differently typed values fit into the same memory
location, since all pointers have the same size. Might not be true for all
languages.
`A or B` needs to be collapsed to one definite type at compile time. It is
typically used for parameter types where the compiler sees which type is given
at the calling site. This is not applicable if you want your return values to
have different types at runtime.
There are multiple solutions.
Well there's a [nim](http://stackoverflow.com/questions/tagged/nim) tag on
StackOverflow. It certainly wouldn't harm if Nim had more exposure there. I
think this forum should be more for discussions which do not fit into SO's Q&A
format.
proc compile(code: string): {.compileTime.} NimNode =
This is a syntax error because the proper syntax would be:
proc compile(code: string): NimNode {.compileTime.} =
Partly related: Ada is in a similar state. In the rationale of Ada 83, pragmas
were described as hav
This happens because `/` on ints returns a float. You want to use `div`
instead, which is integer division.
var maxLignes = ((nombreDePyramides + 2) * (nombreDePyramides + 3)) div 2 -
4
Or, alternatively, convert it – this is clearly the inferior solution, but
given here for
Some thoughts:
The idea seems to be basically what Java does with `*.jar` files. And you say
Tcl also does it. So why can they do this? They can because running both a Java
application and a Tcl script requires a runtime environment (Tcl interpreter /
JRE) on the target machine. So if the user
Having a GitHub account should not be required to participate in the community
and I think it's harmful to make people with few original Nim code second-class
citizens.
Interesting. I only remember that Araq once explained that strings and seqs are
heap objects managed by the garbage collector, but I may have misunderstood it.
In any case, there should be some official documentation about this.
> When a shallow sequence is resized, only the variable currently being
> modified has its reference updated; the other variables will still have
> references to the old data.
proc foo() =
var a = newSeqOfCap[int](2)
a.add(1)
var b: seq[int]
shallowCopy(b, a)
I have heard that 2017 will already be the year of Linux on the desktop, so Nim
might have to wait one more year.
> Is it possible to use Nimscript as an embedded scripting language
In theory: Yes, of course. Why shouldn't it?
In practice: Since the compiler and the standard library are rather modular,
you can include parts of it in your project. However, there is no API dedicated
to what you want to do, s
> And usually there are no parts in the AST that are "always" there to always
> ignore
Well that's good to know :). I wrongly assumed by testing that the `RecList`
will always be there.
Consider this code:
import macros
dumpTree:
type
ObjectKind = enum
oA, oB
ObjectType = object
case kind: ObjectKind
of oA:
a: string
of oB:
b: string
ObjectType2 =
`loadToJson` ignores tags because the JSON structures do not know anything
about tags. You have several options:
**Using the serialization API with an implicit variant object**
First, you need to define the type for the tag `!remote`. You need to tell
NimYAML how to load that type. Then, you de
Since YAML is a superset of JSON, you can use
[NimYAML](http://forum.nim-lang.org///nimyaml.org) to deserialize the JSON
file. It is able to automatically map a JSON object to a Nim object:
import yaml.serialization, streams
type Config = object
rootDev: string
Wouldn't it make more sense to bind Nim to Android NDK? I think you would have
a hard time to call Android UI libs through jnim, unless you provide a thick
layer. There is also
[NativeActivity](https://developer.android.com/reference/android/app/NativeActivity.html)
which enables you to write p
NimYAML 0.8.0 is now available. Its focus was on making it more capable of
being used for configuration files:
* You can now set default values of object fields with `setDefaultValue`.
* You can now mark object fields as transient with `markAsTransient` so that
they are not serialized or exp
I wonder why this fails:
type
Iterable = concept c
for i in c: discard
proc test[T](x: T) =
echo x
proc test(x: Iterable) =
for i in x: echo i
test(1)
test([1, 2, 3])
Shouldn't `Iterable` be a better match?
I explained some basic metaprogramming stuff in my [article on
NimYAML](https://flyx.org/2016/09/22/nimyaml/). Actually,
[NimYAML](http://forum.nim-lang.org///nimyaml.org) as a whole is a good example
of metaprogramming usage, because what is does is not doable in most other
languages (though s
Wow, I never thought of that. With this, we can write
[fuckit.nim](https://github.com/ajalt/fuckitpy)!
If you write the module yourself, the simplest way would be:
macro myMacro(body: typed): typed =
# do things here
#
# do not forget to add the original procs to the output!
myMacro:
proc proc1*() = discard
proc proc2*() = discard
# .
The Nim compiler has the `rst2html` action which transforms a reStructuredText
file to HTML. It can do everything Markdown can, plus some extras (e.g. Nim
syntax highlighting). By default, it uses the same HTML template which is being
used for generating API documentation (with `nim doc` / `nim
node.repr
var p = cast[ptr fuck](L.newuserdata(sizeof(fuck).cint))
You allocate memory which is **not zeroed**. So its content may change
depending on what it was used for beforehand.
echo repr(p)
Now you want a representation of that memory. `p.ud` may have any value here.
I
Yes, Stefan's solution is somewhat nicer, didn't think about that. If there is
more data involved, split may be further accelerated by setting `maxsplit`:
let (lookup_id, lookup_name_source) = p.rowEntry(col).split('|', 2)[0..1]
I cannot really answer the question whether there are missed optimization
opportunities in Nim's SQLite wrapper, but being a wrapper, it sounds unlikely.
There are some things about your code I can comment on:
lookup_id = p.rowEntry(col).split('|')[0]
lookup_name_source = p.rowE
Here is how you can do it with premature optimization:
import unicode, strutils
proc translationTable(src, dest: string): array[0x1f00, char]
{.compileTime.} =
for i in 0..<0x1f00: result[i] = '\0'
var
srcIndex = 0
destIndex = 0
while srcInd
Your compilation instructions would probably be nicer if, instead of depending
on absolute paths and symlinks, there would be a Makefile like this:
board: board.nim engine.nim
nim c -p:../nim-gio/src -p:../nim-atk/src -p:../nim-glib/src
-p:../nim-gdk3/src -p:../nim-gtk3/src
://github.com/flyx/NimYAML/issues/24).
* YAML compliance has been improved.
A complete list of changes is available
[here](https://github.com/flyx/NimYAML/blob/devel/CHANGELOG.md). NimYAML 0.7.0
requires Nim 0.15.0.
What is _code_? An INI file also contains _code_, i.e. some text structure that
complies with a grammar. You also need a parser to read it programmatically.
You may want to post some references about what's the problem with Python's
setup.py, because from what you write, it doesn't seem obvious.
You can define any custom commands you want by putting them into `config.nims`
at the root of your project. For example, this is what I have in NimYAML:
task tests, "Run all tests":
--r
--verbosity:0
setCommand "c", "test/tests"
This basically tells Nim to exe
`application/json` is not a supported enctype in HTML. See [MDN
documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype).
There was a [proposal](https://www.w3.org/TR/html-json-forms/) for it - note
the giant yellow-dotted banner there. It is not actively maintain
> This will work if I use @["", ""] instead, but I don't see why I have to?
Because `match` takes an `openarray[string]` for `matches`. It means that the
proc works with both an array and a seq. And an array cannot be extended.
Since the number of matches in your PEG is statically known, it simp
> would the executable be usable in other machines with the same operating
> system?
In general, yes.
> Is it standalone?
Depends on your definition of standalone, I guess. For a simple test
executable, `ldd` yields:
linux-vdso.so.1 => (0x7fff641ee000)
libdl.so.2 => /lib
I agree that it would be able to determine wether this is a proc call or a type
conversion from the parameter type. This can be a feature request.
It is probably not so simple to issue a warning with such conflicts, because
the type may be defined in one module, the proc in another module, and b
Where would the compiler bug be?
You define a proc named `int`, so when encountering `int(k)`, the compiler
tries to call this proc instead of doing a type conversion. I'd say, it behaves
as expected.
Since types are not keywords in Nim, it is not per se illegal to name a proc
`int`.
Partly related: I know that GTK's support for Keyboard layouts on Windows is
rather broken, because they do not use the API as they should. This has forever
been a problem with the Neo layout I use for typing. It is no problem on OSX or
Linux. GTK devs marked this issue as _wontfix_. But I am no
> Everything is split more explicitly, and there is no system wide hybrid type
> that has to be compatible with whatever the backend is.
So, one cstring for `char*`, one for `std::string`, one for `NSString` and one
for JS' `string`? That looks like an awful lot of string types.
I created a pull request that fixes this:
[https://github.com/nim-lang/packages/pull/408](https://github.com/nim-lang/packages/pull/408)
> I mean somehow I have to tell Nim when to free memory right?
Yeah sure, you just use these:
[alloc](http://forum.nim-lang.org///nim-lang.org/docs/system.html#alloc,Natural),
[dealloc](http://forum.nim-lang.org///nim-lang.org/docs/system.html#dealloc,pointer),
[allocShared](http://forum.nim-
Yeah, if `ref array` does not work properly, it should indeed produce a
compiler error. You should file a GitHub issue.
As I said, you cannot create a _dynamic_ tuple. The tuple type must be fixed at
compile time.
I believe you will get better answers if you show example code with an input
sequence, and expected output. For me, it is still rather unclear what you are
trying to achieve, because when you have a se
You cannot have `10` and `'a'` in the same sequence. `10` is an `int`, `'a'` is
a `char`.
It is not clear what exactly you are trying to accomplish.
d = (b: 10, c: "cd")
This already creates a tuple and is not a sequence. How does the sequence you
talk about look? Since the tuple needs one `int` and one `string`, you would
not only need to map the sequence items to
The text I quoted said _consider_. Not _do not use black_. The author
considered it and decided to use both black and dark gray text (see the text in
the margin and the footer?).
Another opinion on text color from
[here](http://forum.nim-lang.org///practicaltypography.com/color.html):
> But consider making body text on screen dark gray rather than black.
> Screens have more severe contrast than paper, and thus are more tiring to
> read at full contrast. This is b
> I have yet to seen a single example of anybody using namespacing in
> functional programming. Then again, its relative "new" in PHP. rofl
PHP is all but a functional programming language. I think you are confusing
terms here, _functional_ programming languages are things like Haskell, Scheme
> Is this implying that sufficiently large codebase of any other (or of a
> specific programming language) would look any better? I don't think so, but
> i'd like to hear about that.
Almost all codebases of large applications look awful. There are a lot of
reasons for that other than programmin
> In general object oriented programming results in a more clean code base (
> example ).
Have you ever seen any codebase of a sufficiently large Java
library/application? I have yet to see _one_ example where OOP lead to a
cleaner code base. [This image is usually a pretty accurate description
cblake: C11 made VLAs an optional feature though. I consider C VLAs a very poor
solution; as you say, it's mostly syntactic sugar for alloca.
And yes, something between array and seq would be nice. But currently, Nim's
type system does not allow a type with a runtime-calculated length parameter.
Stefan_Salewski:
> May it be possible to have one single Seq in each proc on the stack? Of
> course it has to be the last element, and can only work when that proc do not
> call other procs.
That may be possible, but far too complicated with far too few impact on
performance. The compiler woul
> I do not understand the use of the openarray parameter in relation to
> performance.
`openarray` has nothing to do with performance. It is just a feature to allow
implementing procs that take both an `array` and a `seq` as parameter.
The actual performance gain stems from using arrays instead
Well, I'm done with ideas. If you want to investigate further, I guess gdb or
lldb would be able to help you see what's happening.
On second thought, the scheduler may be intelligent enough not to start more
than one thread if it knows that they all wait for the same resource. But I
wouldn't assume it.
Well it works for me with 32 characters in the string (Linux, 4 CPUs). So it
seems to depend a bit on the OS - and therefore, the scheduler.
> I think this shouldn't be the case.
I'll try to explain what might happen. I do not know all internals involved, so
it may or may not be accurate.
Supp
The problem is that threads _go to sleep while still holding a lock_.
Well, the real problem is that afaik there is no guarantee that this code will
ever finish, because the scheduler is not required to ever wake the right
thread when a bunch of other threads are still waiting. But anyway, Movin
@luntik2012: From documentation of `execProcess`:
> WARNING: this function uses poEvalCommand by default for backward
> compatibility.
This means that it executes the command within a shell, which is probably
responsible for the trailing newline.
@Stefan_Salewski: Well, it's easy enough to imp
The problem is that the result of `execProcess` contains trailing whitespace (a
newline in this case). Try:
return execProcess(command & "" & filepath & ) /
1000""").strip.parseInt
Look
[here](http://forum.nim-lang.org///nim-lang.org/docs/manual.html#statements-and-expressions-assembler-statement).
Compile your plugins with `--app:lib`, then use the `dynlib` module in the main
program to load them at runtime.
Usually, you would define `action` as `proc(l,r: T): T`. But this does not work
for `xor` because of this paragraph in the manual ([see
also](https://github.com/nim-lang/Nim/issues/2172)):
> Assigning/passing a procedure to a procedural variable is only allowed if one
> of the following conditi
This is not possible by design.
type
test* = object
Here, you declare an object that has no fields.
var t = test()
Here, you instantiate this object. `t` has the type `test`.
var t.name = "kek"
The compiler now looks at `t`'s type an
The OpenGL wrapper provides a `GLvectorf3` type, why don't you use that? Also,
you should show more of your code for us to see what you are actually doing.
> I hope I'm wrong and there is an elegant way to define a large tuple.
What do you need a tuple this size for? Your problem is likely that you use the
wrong tool for the job. The need to write
var myTuple: tuple[a00,a01,a02,a03,a05 ... a98,a99: int]
roots from the nature of t
You cannot `gensym` the pragma since it is injected as parameter. But you can
simply enclose the template body in a block:
template foo(txn, body: untyped): untyped =
block:
let txn = 1
body
foo hello:
echo hello
foo hello:
echo hel
proc fillTuple[T: tuple, V](target: var T, input: openarray[V]) =
var index = 0
for field in target.fields:
assert input.len > index
field = input[index]
inc(index)
var myTuple: tuple[a,b,c: int]
fillTuple(myTuple, @[1, 2, 3])
Or, if
Works for me on devel. However, the bit with the `include` does not.
import macros
macro addEcho(s: untyped): stmt =
s.body.add(newCall("echo", newStrLitNode("OK")))
result = s
proc f1() {.addEcho.} =
let i = 1+2
echo i
You have to use untyped because with stmt, Nim seems to create a symbol f1
beforehand and then
94 matches
Mail list logo