How about this:
type
Widget* = ref object of RootObj
Layout* = ref object of Widget
widgets*: seq[Widget]
Button* = ref object of Widget
proc newLayout(): Layout =
result = new Layout
result.widgets = @[]
proc
Hi Nim community!
I am a new user of Nim language. It's very fun to program with.
To know Nim better, I am creating a mini GUI for fun. I am currently facing a
problem that I can not solve ..
I wish I could fill a sequence of widgets with different types (Layout, Button,
..) but with a common
There will definitely be some Nim people there. I might join (still not 100%
sure if I will though), in any case I'll see you at the stand hopefully
I've been looking into this for a while, and I can't seem to come across the
culprit. `localBounds` returns a `FloatRect`, which is a `{.bycopy.} object`.
It is not a `ptr object`. I am a bit confused myself.
Here's what I think I've deduced so far:
* `viewport(view: View): FloatRect` is anot
In my module, I'd like to do something like
when defined(nre):
import nre
# code that works with regular expressions
so, if the user does
import nre
import my_module
then that code gets compiled, but if the user doesn't use nre, then we aren'
@woggioni The GC is involved in your example because the `proc(): auto = pt` is
a closure; it captures `pt` as part of its environment.
Closures in Nim are bound to the thread that creates them because the closure's
environment is allocated on the thread-local heap (managed by the thread's GC).
That's weird. I wonder if it's really nil, or if it's an invalid memory
location. It is a segfault, so... could be either.
Now looking at the repo. If it segfaults there exactly, then it probably isn't
the text that is null.
That could work. I would be concerned about something though: will binary zero
always mean that it is safe to change branches? It is possible that a varient
may be perfectly valid as zero, even when initialized. An example could explain
better:
type
Variant = enum
Poi
@mashingan this confirms that even local value-typed variables are GC managed..
But using ref doesn't solve the problem:
type
P2d = object
x, y: float
P2dp = proc(): ref P2d
var thef: P2dp = nil
proc foo(): auto =
var pt :
DLL building has a couple of open bug reports, not sure if they affect Windows
though. VTables are easy to do but independent of "interface"ing with other
languages like Delphi.
Another solution is to allow object case transitions when the object consists
of binary zeros which is what `reset` does. `reset` is documented to enable
object case transitions. This would not require a hidden `wasInitialized` bool.
Are you sure it's localBounds... maybe the Text itself is null?
I'll look at this more in depth later today. Currently at lunch.
Anyway, I am a big fan of SFML, and I'm wondering if localBounds is even
supposed to ever be null...
Maybe the rectangle was never set.
FOSDEM day is approaching,
Is anyone planing to join FOSDEM beer event tomorrow evening?
I'm new to Nim - bought the book and will be getting started soon. I'm mostly
using Delphi for fat clients - I've no plans to change that but would like to
start implementing some functionality in Nim. I make extensive use of
interface-based Delphi DLLs (i.e. I return an interface reference to t
@woggioni, how about adding threading to your example, like
# compile with --threads:on --threadAnalysis:off
# because this thread need to modify `thef` value
type
P2d = object
x, y: float
P2dp = proc(): P2d
var thef: P2dp = nil
@twetzel59, there is extra warning you can enable that you can find useful:
warnProveField
Just as an idea, the flexible solution would be to able set discriminant if you
provide the new value simultaneously with discriminant and reject at compile
time otherwise.
Something like:
var t = Thing(kind: Zeroth, f: 3.14)
t.kind = First # not compiles
t.i = 12 # fa
It is reasonably easy to fix but adds 1 byte to case objects. The cause is that
code like `n.kind = First; t.i = 8` needs to work, so transitions from the
"zero" state have be be allowed. Alternatively we can require full object
constructions and disallow all assignments to the discriminator. Th
If you see this
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
STARTTLS has already happened and OpenSSL has already come into play since that
message comes from 'ssl_err.c:665' in OpenSSL source code (the line number
refers to version 1.1.0g). There must be
> @mikra "After the fact", it totally makes sense to me that I would need to
> keep a reference to a thread. But as I was writing the code, it wasn't
> obvious at all, because I'm used to Java, where threads are "allocated on the
> heap", and so they don't get destroyed by leaving the scope wher
When quit() is called in try block, the finally block is not executed. It is
only executed after normal finish or exception is raised. I got around the
problem I needed to solve with addquitproc but I am curious if this is how
'finally is supposed to work in nim.
proc qproc(){.noco
There seems to be a bug, however, by which this check doesn't catch such an
error, even in debug mode.
For example, try the following example.
type
Kind = enum
Zeroth,
First,
Thing = object
case kind: Kind
of Zeroth:
f: fl
24 matches
Mail list logo