So is the book out already and if it is what is the title and please leave a
link to the PDF thanks
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* =
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:
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
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
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...)
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
> 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
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:
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.
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
I'm still excited fwiw, it means we got it essentially right. ;-)
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
you are returning value, not reference. change return type to var Child
oh :/, that was a long mail to describe that
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
get_child returns a Child, not a var Child
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()
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
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.
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
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?
@mashingan it seems there is a offset error in the code (files are not
identically but shifted by some bytes at certain offsets)
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.
Ok even if i don't like multiple ways for doing the same thing thus i would
deprecate finalizers in dev.
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
> 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 -
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 =
28 matches
Mail list logo