Book for beginners

2020-01-19 Thread Cnerd
So is the book out already and if it is what is the title and please leave a link to the PDF thanks

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread Hlaaftana
I know this code isn't meant to be used, but the given answers for `var Child` were wrong to the point where I have to respond. We want the variable `self.child` not `child`. No need for templates or anything type Child* = object value: int Parent* =

Nim will silently auto convert a float64 to a float32 and loose precision... is that good? Thoughts?

2020-01-19 Thread treeform
I get why float32 can auto convert to float64... there is no loss in precision. But its strange to me that reverse is also true. Nim will auto convert a float64 to a float32 and loose precision!!! Silently! This is not true for ints. Here it states so in the manual:

Re: Closure iterators and resource management

2020-01-19 Thread spip
Just to add that I understand that the iterator can be resumed, so perhaps freeing resources must not be part of the code of the iterator, though it should access variables declared in the iterator... proc main = let iter = stream(parseInt(paramStr(1))) for i in

Re: Naming conventions - need leading underscore

2020-01-19 Thread cblake
Another possibly constructive, possibly not suggestion (that would have prevented this entire thread from happening, as just one example) is to have "more room" for convention support. For the root of this thread, we could have identifier normalization not collapse '_' at the beginning (or

Re: Naming conventions - need leading underscore

2020-01-19 Thread Araq
Huh? We do have `--styleCheck:error` and I personally ensured the full stdlib and compiler source code works with it. In fact, for the compiler it's always enabled so that every contributor has to obey. (Though there seems to be a bug with it that I need to look into...)

Re: Naming conventions - need leading underscore

2020-01-19 Thread cblake
This is simply a judgement call of the compiler authors to name the command "lowercase gcc" to avoid inflicting caps lock or shift on people, but it's a judgement call the case-sensitive file system enables rather than blocks. When I say `whence -m '*[A-Z]*'|wc` in Zsh. I get about 200 commands

Re: Naming conventions - need leading underscore

2020-01-19 Thread Araq
> Personally, I like just full sensitivity best. This is of course a valid opinion to have, but what I'm missing in these discussions is that Unix's case sensitivity introduced a de facto standard of alllowercase for every command. In other words, whenever you type `gcc ...` on the command

Closure iterators and resource management

2020-01-19 Thread spip
How can a closure iterator manage resources? In my particular case, I have a closure iterator that create channels and threads. When the iterator is aborted from the caller side, how can I free the resources I have allocated in the iterator? For instance, consider the following example:

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread Araq
Polluting your APIs in order to support "chaining" is a bad idea. Wait for [https://github.com/nim-lang/Nim/pull/13092](https://github.com/nim-lang/Nim/pull/13092) instead please.

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread solo989
working solution all in one snippet type Child* = ref object value: int Parent* = ref object child: Child proc set_value*(self: var Child, value: int): var Child {.discardable.} = self.value = value return self

Re: [C++ coroutines] in GCC

2020-01-19 Thread Araq
I'm still excited fwiw, it means we got it essentially right. ;-)

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread ducdetronquito
Hey ! Thanks you for the quick answers ! As @solo989, just returning var Child like in the snippets below does not work has it triggers a compile error. proc set_value*(self: var Child, value: int): var Child {.discardable.} = self.value = value return self

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread SolitudeSF
you are returning value, not reference. change return type to var Child

Re: [C++ coroutines] in GCC

2020-01-19 Thread mratsim
oh :/, that was a long mail to describe that

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread mratsim
You don't need `var` in any of those procs because you are using ref objects and you are modifying the memory pointed to by the reference, not the reference itself. i.e. this compiles type Child* = ref object value: int Parent* = ref object

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread dawkot
get_child returns a Child, not a var Child

Re: How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread solo989
You need to make the return value var as well. proc set_value*(self: var Child, value: int): var Child {.discardable.} = self.value = value return self proc get_child*(self: var Parent): var Child {.discardable.} = var child = Child()

How to chain prodecure calls that mutate a reference object ?

2020-01-19 Thread ducdetronquito
Hi there ! I am trying to chain procedures that mutate a reference object, but I can't managed to do it. Here is a minimal example: type Child* = ref object value: int Parent* = ref object child: Child proc

Re: [C++ coroutines] in GCC

2020-01-19 Thread treeform
I was excited about this till I read this: [https://news.ycombinator.com/item?id=22090942](https://news.ycombinator.com/item?id=22090942) If the author is to be believed its just a transformation that is applied to the code. Basically the same transformation that we do with async/await already.

[C++ coroutines] in GCC

2020-01-19 Thread mratsim
This thread details the coroutines API for C++: [https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01096.html](https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01096.html) Just like we map to C++ exceptions, it's probably worthwhile to have coroutines that map cleanly to C++ coroutines so that we can

Re: How to upload large files efficiently and quickly with Jester?

2020-01-19 Thread mrhdias
Thanks @mashingan, I tested the code and it is awesome :-) But @mashingan is right, the size of the files is different from the size of the uploaded file (I think it's an easy fix error)! Will the websocket work if I use the nginx as a frontend with ssl?

Re: How to upload large files efficiently and quickly with Jester?

2020-01-19 Thread enthus1ast
@mashingan it seems there is a offset error in the code (files are not identically but shifted by some bytes at certain offsets)

Re: How to upload large files efficiently and quickly with Jester?

2020-01-19 Thread enthus1ast
thank you @mashingan for this snippet, i did not know that jester can websocket nowadays. And the slice thing is a nice trick as well.

Re: Finalizers questions

2020-01-19 Thread filcuc
Ok even if i don't like multiple ways for doing the same thing thus i would deprecate finalizers in dev.

Re: Naming conventions - need leading underscore

2020-01-19 Thread cblake
One thing often missed in discussions of insensitivity is the very different user scenarios of "interactive" vs. "written once to be read many times". Insensitivity tends to be more popular in the interactive/IDE/REPL setting in the same way as TAB/whatever auto-completion. My first encounter

Re: Naming conventions - need leading underscore

2020-01-19 Thread cumulonimbus
> Hungarian notation encodes the type in the name and is widely regarded as the > wrong idea. Why should it be any different with visibility. While i completely agree, it is my impression that it is really helpful for beginners to carry around the type information in their first few programs -

Re: How to upload large files efficiently and quickly with Jester?

2020-01-19 Thread mashingan
Uploading file has been tricky, but thankfully nowadays there's websocket to send blob. Here's example how to send a file. import os, jester, asyncdispatch, htmlgen, asyncfile, asyncstreams, streams import strutils import ws, ws/jester_extra settings: port =