This is my solution to call functions by name:
[https://github.com/krux02/opengl-sandbox/blob/master/examples/console.nim](https://github.com/krux02/opengl-sandbox/blob/master/examples/console.nim)
This example in this project does not have any dependentcies of that project
itself, it should
I made a Video showing how to use an arbitrary GLSL shader and integrate it
into a Nim/SDL/OpenGL application.
[Here it is](https://www.youtube.com/watch?v=mcMr142BxtI)
This should be an automatic solution for this problem:
[https://github.com/nim-lang/Nim/pull/10569](https://github.com/nim-lang/Nim/pull/10569)
strings in Nim don't have any special Unicode support. Unicode is just designed
in a way that it is compatible with ASCII. When a utf8 string contains a
non-ASCII character, it will create it as a multibyte character. But all
individual bytes of this multibyte character will have a value above 1
I don't know how `castPointer0` is used. But my experience tells me it should
never have been used in the first place. You can only take the address of the
first element of a string when the string is not empty.
Create an issue in the issue tracker.
[https://github.com/cheatfate/asyncpg/issues]
var a = ""
With `a[0]` you expect to get the null terminator. Neither in old nor in new
Nim you are allowed to write to it. With `addr a[0]` you get the address of a
null terminator that you are not allowed to write to. You just should not do
that. Btw `addr a` is possible though. But
well you have a bug in your code, `^0` actually indexes the 0 terminator of a
string, and this behavior is correct. Use `^1` instead.
You should put the problem you are describing in the title.
This discussion is pointless and triggers too much attention. `sizeof(float)`
won't change. if you want 32 bit float use float32.
I haven't been on the forum for quite a while, just the chat and I would also
like to put my wishlist of things to remove here.
* the range type. Well just use `type range[low,high: static[int]] = distinct
int` No need for this to be a language feature
* arrays with a size that is not an int
you should be able to just remove the ref in Token = ref object. That is one
layer of indirection less, and therefore faster and less memory consumption.
And a little comment on what you are doing. Tokens are not nested. What you are
doing is already parsing. In brainfuck all tokens are characte
There is also:
> * there is also manual cleanup proc with defer
>
let vao = createVao()
defer: vao.delete
> * don't clean up at all. Resources are freed at program exit anyway.
>
There is no best way. There are only advantages and disadvantages. Choose
wisely depe
Techniques for dealing with lack of motivation, malaise, depression
Well, you are not the only one who wants this. I also have my opengl wrapper as
part of my program here:
[https://github.com/krux02/opengl-sandbox/blob/master/fancyglpkg/glwrapper.nim](https://github.com/krux02/opengl-sandbox/blob/master/fancyglpkg/glwrapper.nim)
Well when the holes are not too big, then an array is still suitable.
Be aware you can create compile time variables and constants. compile time
variables are only existent at compilation time, but can be modified, and
constants are readable at compilation time as well as at runtime.
Nope, what you are looking for does not exist. All you can do is rename the Nim
version of that Identifier. Be aware there are already two sdl2 wrappers
around. I don't think that yet another will help anybody except yourself in
learning how to write wrappers.
[https://github.com/Vladar4/sdl2_n
Vulkan introduced the _Standard Portable Immediate Representation_ (SPIR-V).
You can imagine this as some sort of assembler instructions that will be
compiled and optimized to the final GPU instructions from the GPU vendor
driver. SPIR-V is through extensions and the latest core version also ava
I remember reading from the factorio blog, that they had desync problems,
because the math library in C++ can behave slightly different on different
compilers for C++. Nim inherits this problem. I am sorry I can't quote it
though.
I am interested in what conflicts you have, so that you really want to use the
`from foo import nil` pattern. I had conflicts, too. But I never thought about
using that pattern. Because even if there is a name conflict, it does not break
the import I just have to be more specific for that name c
@jacmoe, no it's not. It is [code
smell](https://en.wikipedia.org/wiki/Code_smell)
My intuition tells me that you did something wrong in your types, if you want
to convert an object to a tuple or vice versa. Try to redesign your code so
that you either only use tuples or only use objects, but don't try to make
mixing them up easy.
If you still want to make it easy to mix up t
@rayman22201 I did the mistake you did, too in the beginning. tuple and object
are both value types like a C struct, and there is no hidden vtable in an
`object` unless you inherit from `RootObj`. I think the documentation is
misleading here.
Pull requests that include an example in the doc comment are generally welcome.
I think you should use `object`, it is the equivalent of `struct` from C.
type
Vec2i = object
x,y: int
Vec2f = object
x,y: float
NVGglyphPosition = int32
GlyphArray* = array[100, NVGglyphPosition]
TextBuffer* = object
posit
@dom96 I am fairly sure that I submitted a pull request (that got accepted) not
that long age that fixed the doc comments.
There is one thing where I would like to add my two cents:
Copy and move semantic which are a delight to use when writing performance
critical code specially. I think Nim is poor in that regards as it deeps copies
seq (vectors) and string by default
It is true that Nim does no
ther is a languare that supports what Ikalman does, it is scala. Here an
excerpt from the repl.
scala> val a = Left(123)
a: scala.util.Left[Int,Nothing] = Left(123)
scala> val b = Right("hallo")
b: scala.util.Right[Nothing,String] = Right(hallo)
scala>
blah blah blah:
type EitherSide = enum
ok, err
type Either[L, R] = object
case kind: EitherSide
of ok:
mleft: L
else:
mright: R
proc `right=`*[L,R](this: var Either[L, R]; value: R): void =
this.kind = err
this.mrig
I got my book today. Yay 💃
well, I would create simd aware types that have operators overloaded. And then
I would cast to these type to use simd.
# let's assume `vec' is the type with simd enabled
var myArray1 = [1,2,3,4,5,6,7,8]
var myArray2 = [1,1,1,1,1,1,1,1]
let view1 = cast[ptr
Write a game
Well as I found out, my Book is on the way, too. Yay. Well you did not get my
feedback during the development of the Book, but I think you will get my
feedback when I read it. Then you can use it for revision 1
Can you put the paper on a link that is not behind a paywall? I am normally
pretty trained to port from different languages to different languages, but
from the paper I can't do copy paste at all.
About the `#? braces` feature. I didn't know about it, but I actually do like
it. I just prefer `{}` over indentation based blocks. But yea I think I can
live with them going away. It's not essential.
I totally agree with you, debugging is really a weak spot in Nim.
Things I just don't understand:
By default Nim does build in debug mode, but it does not provide debugging
symbols (`-g` flag for the C compiler), so that you can't actually debug with
gdb your debug build. When I complain that t
I implemented two optimizations for the `Option` type. The idea was to do the
same as the Rust compiler, use the nil/nullptr for the none option without
occupying extra memory. Then I had a similar idea for `Option[Natural]`, where
I could use `-1` internally to store none. That type could be us
well, I once did an approach to this, feel free to use it.
This macro embeds the gdb python script into the executable, when it is build
on Linux. Alternatively you can also load the script from gdb, but once this
works there is no hassle involved anymore.
[https://github.com/krux02/opengl
Thank you, and yes it is related. When I touch code of strings, everything
becomes important.
Ok the problem is somewhere in the garbage collecter. It tries to create an
object and fails. My motivation to fix issues with the GC is pretty low. I
would spend my time rather on removing the dependency on the GC than to fix the
problem with it.
well I did something in that direction on a branch. I have a problem with the
nim compiler to crash here and there. How do I enable debug information again
in the compiler? And why is is such a hassle in nim to get debug information?
Debug builds should have them.
you can do this:
import algorithm # algorithm contains the sort function
var x = "bad cab" # `var` is for mutable
x.sort(cmp)# default comparison function `cmp` from system
echo x # prints " aabbcd"
well are you open for a pull request for that. I think that's easy to implement.
Well I don't know much about UDP. But in all tcp connections I had so far I
first needed to open a server that listened on a port and then I could connect
to it. You only had a dial that is confusing to be. Good to hear that you are
still around btw
well according to the documentation you have to create a server first with
`newSocket`, and then you can connect to that socket.
The title is the question. I would like to contribute, if I can (maybe).
Have you thought about creating an issue on the github page? I doubt that the
developer still checks these forums.
Contribution is always welcome. You are welcome, too. Thanks.
Well nim is based on being able to compile to C. But the C code is not for
readability. Even though it is quite readable.
Truth to be told, Nim is not yet Nim 1.0 and there is no 100% guarantee that
code that you write will always work in the future. But I use a lot of
metaprogramming and breaking changes are very rare. But normally when things
change, the language wants you to improve your code and changes are ver
well the SDL2 library is just a wrapper, and it is supposed to expose the API
it wraps and nothing more. It could have convenience functions but so could you
provide it.
you can also add all c files of raylib manually with the compile pragma, like I
did it in AntTweakBar
[https://github.com/krux02/nimAntTweakBar/blob/master/AntTweakBar.nim#L43](https://github.com/krux02/nimAntTweakBar/blob/master/AntTweakBar.nim#L43)
well you can create your own StringSlice type that does not copy and override
the slicing:
type
StringSlice
src: ptr string
a,b: int
proc `$`(arg: StringSlice): string =
(arg.src[])[arg.a .. arg.b]
well importing in a local block/function has nothing to do with runtime
importing. Just see scala import.
[https://en.wikibooks.org/wiki/Scala/Import](https://en.wikibooks.org/wiki/Scala/Import)
and yes for your case use a when clause. The content of a when brach is at top
level it does not cre
well I always put my breakpoints on functions. So like this
(gdb) b foobar
(gdb) b foobar_123456789987654321
it is a bit more robust on the terminal than lines. And don't underestimate
`(gdb) tui enable`. I wasted a lot of time with GDB. I think it's a horrible
interface,
Well, I would document it properly. Nim is so flexible I would not know about
anything you can emit that works only top level. Maybe you can emit a function
declaration that is C calling convention. Not sure if it works though.
The random module is not very good at all, sorry for that. But there is a
mersenne twister in the standard library.
This is what I use. Upper bound is exclusive.
proc rand*(maxval: uint32): uint32 =
let limit = uint32(high(uint32)) - uint32(high(uint32)) mod maxval
var
well sdl2 is not part of the standlard lib, it is just on the nim-lang github
account. And `IMG_SavePNG` from SDL2_image is not documented. It works and can
be used but it is non-official.
Well when it is about, what could be ported, I would add this, but it is
currently without a nim version:
Well there are [tables](https://nim-lang.org/docs/tables.html#initTable,int)
all in memory, just not very persistent
hmm, I am a bit surprised, I would have guessed the following parsing rule:
echo b, c d, e f g, h
echo(b, c(d, e(f(g, h # <--- I expected this
echo(b, c(d), e(f(g)), h) # but hey it's this
I did not know this is possible. Seems very interesting.
I think the difference is in the details, but the details matter. I would
really be interested to get some experience from people who actually had
projects in both languages. Because then you get to know about differences that
actually matter.
A tiny feature of the Nim language, the dot call sy
well, not that I know of. You should know that a dot expression can be a
function call, but it can also be an access to an object member. I think you
have to write your own normalization function.
Yes converters are probably your way to go. Probably means that there is still
the option, because there is still case that creating a new type is not the way
to go, and you should just have sticked with using a `table`.
Thanks for the positive feedback. This motivates to do more in the future.
Don't hesitate to ask questions about things you did not understand. When you
ask I knew that you are actually interested in the content.
[https://www.youtube.com/watch?v=JO0iqGDgFqA](https://www.youtube.com/watch?v=JO0iqGDgFqA)
Keep in mind this is my first video that I made to demonstrate something. For
me it felt totally weird to talk to a computer without response. So the slow
speaking is nothing I need feedback about, I think
Well to write wrappers, the most useful tool you have around is c2nim. That
helps you with initial translations. Of course you need to also undersdand how
C works or writting correct wrippers might become a bit tricky. But
definitively check out other wrapper code that was already been written i
Don't use Windows. Seems to be bad software
No seriously. I have no idea. I can only guess what to look for. Does msys2 try
to make `getCurrentEncoding` behave correctly? Does msys2 try to make
everything more unix like and make the shell utf8? Does msys2 have any
information about encoding?
Instead of `eraseLine` you can also always print `"\r"`. That character does
not erase the line, but puts the write cursor back at the beginning of the
line. output after that overrides what is already there. So in this case, where
you always print the full length of the progress bar, the effect
Value types have a good advantage, but the problem is, that when you make them
too big, they could overflow the stack (iirc 2MB on Windows). But you should
use value type arguments, because a ref type can always be converted to a value
type with the `[]` operator.
proc foo1(arg: Ma
Well if you need docx, then find some tools that do your needs in docx. Maybe
you find the right command line tools that will convert the important parts of
your docx files into something that you can process. Then you can continue in
Nim. Maybe you can find a C library that supports extracting
There was a breaking change in the do notation that I don't approve personally
at all. But I thought it was parsing rules only.
Well I would like to have `¬∨∧` as aliases for `not`, `or`, `and`. But it
doesn't seem that I well get it `¯\_(ツ)_/¯`
Normally I would think that when I return a value from a macro or set the
result to that value. There would be no difference. But aparently there is:
import macros
macro testA: string =
result = newLit("testA")
macro testB: untyped =
newLit("testB")
This is just a bug and should be reported
let y: float32 = 47.11'f32
assert y == 47.11'f32 # < this really should be true.
Honestly I don't know. I try to avoid `ref` as much as I try to avoid
`std::shared_ptr` in C++ because for me they are semantically the same. But I
know that the programming language Go does not have distinct types for `ref`
and `ptr`. In that language a pointer simply keeps a block of memory du
@jxy yes there is a difference betwen `ref A` and `ptr A`. When the ref is
implemented as an `std::shared_ptr` (I think Araq mentioned an option once to
do that), then `ref A` takes over the ownership and as soon as the reference is
deleted, also the memory will be deleted. You don't want that,
Wait a moment, are you shure this D code is equivalent to the Nim code you just
posted?
struct Bar { void bar() { "bar".writeln; } }
To me this looks like just a _method_ (in c++ terms). And a _method_ is not a
value member of a struct. In other words it does not increase the
If I remember correctly, the hash function for doubles in Nim is converted over
from LUA. In lua double are often used as integers because for the most part
lua did not have integers like javascript. Therefore the hash function was
chosen to optimize this use case.
I did not try Vulkan yet, but I read a lot about it. More control and so on.
And a unified API for both mobile and desktop. Even more things that you can do
wrong and get a black screen without feedback is not really somethign I am
looking forward to. My library is trying to get exactly this par
> No, the original problem was about removing entries from a CSV file,
> something which grep cannot do particularly well... 
challenge accepted:
grep -f delete -v data.csv > filtered.csv
rm data.csv
mv filtered.csv data.csv
`delete` is the file with the names to dele
You could write a nice 3D renderer for the game
state, with this library:
[https://github.com/krux02/opengl-sandbox](https://github.com/krux02/opengl-sandbox)
But be aware I did not define a fixed mesh format nor an _.obj_ loader because
of it. So the initial renderer would use cones and
since it is basically me who took over the nim_glm maintenance. The version you
fixed is very old and not the version anymore that I maintain currently
anymore. I should mention that I never did performance benchmarks on that
library, only correctness tests. I only applied my knowledge of what i
since it is basically me who took over the nim_glm maintenance. The version you
fixed is very old and not the version anymore that I maintain currently
anymore. I should mention that I never did performance benchmarks on that
library, only correctness tests. I only applied my knowledge of what i
well I know blockout, and I do like it. I actually thought to add a game mode
for blockout, too. But before that, this game needs to become a but fancier.
i can also imagine that the cause of compiles to fail is, that you have a
double definition of the same function when you try to compile the exact same
function again. So I think it would be sufficient to replace the symbolf the
function with a new identifier.
well, when it doesn't work it is probably a Nim bug. Create an issue.
Well I don't know if there is something built into the language to do that
simply. But you can jump to the definition of the proc symbol and get the
implementation. You could add the noSideffects pragma to the function and then
test if that ast still compiles with `system.compiles`.
yay tetris
> here is the sourcecode:
[https://github.com/krux02/opengl-sandbox/blob/master/examples/tetris.nim](https://github.com/krux02/opengl-sandbox/blob/master/examples/tetris.nim)
I just wanted to comment, that tuples have already a `[]` operator. They accept
a static int `n` as argument and return the _n-th_ element of that tuple. It is
not overloadable, but I guess all you have to do is to make it overloadable by
handling the magic in `magicsAfterOverloadResolution`.
Well I realized the single most important information (at least for me when I
came to Nim) is missing on the front page of the new website: metaprogramming.
@Araq Well I did in fact know very little about the possibilities to use Nim
without garbage collection. All I heared about was the `string` and `seq` are
implemeneted in a way that they need the gc to run. Because I did not find any
other documantation I came to the conclusion that disabling th
I found out how to do it:
nim c --lineDir:off --debuginfo compiler/nim
Well, when you say that GC is optional, you should say that disabling it pretty
much makes the types seq and string unusable, and therefore the GC is not
really optional.
I have a problem I have absolutely no clue why this happens:
[https://github.com/nim-lang/Nim/pull/5664](https://github.com/nim-lang/Nim/pull/5664)
In order to find out why this happens I would like to debug the compiler. Since
I think that the problem is somewhere in the generated C code I woul
I like the new website. It shows that this language is living and evolving.
There is only one thing I would like. The menu bar for Documentation should
open like a menu bar on windows and show the links without an intermediate
website. This speeds up navigation.
+--+--
@Fungi well you do not have the best diplomatic strength. When you write in a
Forum for Nim developers that what they are doing is entirely wrong and sucks a
lot, then you will earn a lot of hate. You are right, performance is not
everything. But Nim is not entirely about performance, it is abou
@Fungi, it's nice that you found out that Nim is not the language for you, but
you should understand that everybody's point of view is always a very limited
view on the world. Nobody knows everything. What I want to say is, just because
you don't see the advantages of compiled programming langua
I think for a fair comparison, you should zero out the memory in the
`var`-parameter case, because that is done for the result variable and
therefore would be the only fair comparison. But I think even then it would not
explain the big difference.
@LeuGim well when you have an array of RootObj, not a ref/ptr to RootObj in the
array, the array actually doesn't contain the subtype anymore. So sure when you
iterate and call foo on each object. It does call the method from RootObj, but
only because you actually have a true RootObj value there
@dom96 I am well aware that seq is implemented as a pointer, but it has value
semantics. That is the reason I did not mention it.
var a = @[1,2,3]
var b = a # b is now a new copy of a
1 - 100 of 356 matches
Mail list logo