Enu - 3d live programming and game dev in Nim

2021-02-12 Thread moigagoo
Just wanted to say a huge thank you for Enu! I've finally set down and tried it out, together with my son. It's so much fun! It has even replaced race games for us. He's four and can't read, write, or program but he's building them buildings manually like a pro. And I'm programming huge towers

echo doesn't work correctly

2021-02-12 Thread tbutton
Hi! there is a matrix matrix : array[17,array[17,int]] Run There's a code that displays a picture draw = for y in matrix: for x in y: if(x==1): echo("#") else: echo(" ") Run output must be like ##

echo doesn't work correctly

2021-02-12 Thread aEverr
echo adds a new line, use stdout.write() instead

echo doesn't work correctly

2021-02-12 Thread Yardanico
Echo works correctly in this case - in your case it doesn't work the way you want because you don't need newlines in rows. Your code should be something like this: proc draw = for y in matrix: for x in y: stdout.write if x==1: "#" else: " "

Why `sortedByIt(it.field)` and not `sortedBy(field)`?

2021-02-12 Thread alexeypetrushin
Wondering why sorting defined as `sortedByIt(it.field)` and not as `sortedBy(field)`? [playground](https://play.nim-lang.org/#ix=2Pf0) import std/[macros, algorithm] template sort_by*[T](list: openarray[T], field: untyped): seq[T] = list.sortedByIt(it.`field`)

Templates and include

2021-02-12 Thread mantielero
I am trying the following: 1\. The following works: **a.nim** template test*():untyped = const a* = "hello" echo a test() Run 2\. But the following doesn't: **a.nim** template test*():untyped = const a* =

Nim Design Patterns?

2021-02-12 Thread alexeypetrushin
> Here are some interesting skeletons Thanks, good reading for weekends :)

Templates and include

2021-02-12 Thread mantielero
I don't know why but tend to get stuck in a problem and then find the solution shortly after I post in the forum. The solution: template test*():untyped = const a* {.inject.} = "hola" include b test()

Templates and include

2021-02-12 Thread SolitudeSF
works fine for me

macros - backquote

2021-02-12 Thread mantielero
My bad. I see that I have something wrong elsewhere.

macros - backquote

2021-02-12 Thread mantielero
I am following that approach: macro genModelInstance*( NUMBER_OF_REALS, NUMBER_OF_INTEGERS, NUMBER_OF_BOOLEANS, NUMBER_OF_STRINGS, NUMBER_OF_STATES, NUMBER_OF_EVENT_INDICATORS: static[int]): untyped = let modelInstance = nnkPostfix.newTree

Nim Design Patterns?

2021-02-12 Thread kobi
it has to be readable, and small according to your judgement. a good language allows much factoring, which is an advantage that Nim has. some people may abuse certain features (and lead to the situation you described), but it doesn't mean you need to avoid it where it does make sense. in your ex

Status Desktop - private messenger and more using Nim + QT

2021-02-12 Thread mratsim
I dare say that for an app that was started less than a year ago, by developers who were completely new to Nim that's an achievement. See the debate on what stack to use back in May 2020:

Nim Design Patterns?

2021-02-12 Thread mratsim
Here are some interesting skeletons: /

Nim Design Patterns?

2021-02-12 Thread alexeypetrushin
> I'm a firm believer that the design patterns as popularized by the > Java/C++/C# folks reveal flaws in the language design and not how to address > architecture problems. Agreed. Many OOP design patterns in Java are the boilerplate code needed to compensate for lack of language features. Also

Nim Design Patterns?

2021-02-12 Thread mratsim
I'm a firm believer that the design patterns as popularized by the Java/C++/C# folks reveal flaws in the language design and not how to address architecture problems. Flaws like: * no ADT/variants/sum types (visitor pattern, null object pattern) * no freestanding functions (manager, executo

Nim Design Patterns?

2021-02-12 Thread alexeypetrushin
There's famous Design Patterns for OOP book. **Wonder if there 's Design Patterns for Nim?** A collection of patterns and solutions for common architectural problems. Nim is mix of functional/OOP and so if you already know any functional / OOP language - you will be able to use Nim right away.

How to set filepermissions

2021-02-12 Thread Araq
The `os` module strives for portability, including for OSes that have yet to be written and deviate from the holy Posix design and so the file permissions leave out some options there were deemed to Posix specific. Now you can disagree with this of course, but that is the reason.

How to set filepermissions

2021-02-12 Thread HJarausch
It looks like one can't set the SUID and SGID permissions this way. Probably one has to use the posix module for that. Having to the **os** module and the **posix** doesn't look right. Is there any reason for this situation?

Is "global_state" a special name in Nim's internals?

2021-02-12 Thread PMunch
I've run into this in the past, but I was quickly able to figure out what was going on. But I agree that this should definitely be a warning or even an error, so I created an issue for it:

macros - backquote

2021-02-12 Thread PMunch
This is a bit tricky, looking at the output from `dumpAstGen` you can see how to generate a node like that. Easiest is probably to create it as a variable and then insert that: `var typeNode = nnkAccQuoted.newTree(newIdentNode("type"))`and then simply use ` `typeNode` ` in your expansion.