> So soemthing like Python's setattr() doesn't exist then?
I think when you want support for dynamic runtime attributes, you have to
prepare for it in a compiled language. For example you can add a field of type
seq or table to your object and a proc for adding data to this field. Of course
in
So soemthing like Python's setattr() doesn't exist then?
Rust, by design, also has C++-like monomorphizing templates, so I think it
isn't fair to imply that templates (i.e., generics implemented by
monomorphization) are a "considered harmful" language feature these days. As
Araq points out, D, especially D2, is a template heavy language which mostly
> Which ones exactly? LLVM, wxWidgets, Urho3D, Ogre, Unreal Engine 4 and even
> GCC afaik all use templates. We're not in the 80ies anymore where templates
> where this special bug ridden feature with stupid syntax that nobody
> understood.
Ok, I will search for examples, and update the post ac
Nice work, but please refrain from facts/myths that don't have anything to do
with your otherwise very nice article.
> This is so bad that several bigger c++ projects completely abandoned
> templates.
Which ones exactly? LLVM, wxWidgets, Urho3D, Ogre, Unreal Engine 4 and even GCC
afaik all use
This is not a question, more like a blog post. I don't have a blog so I do it
here. Feel free to comment or ask questions.
In my past I have learned the programming language Go, and I really started to
like the interface type that Go offers, and I wondered, weather it is possible
to port this g
Afaik it is not. You could use a JSON Object for example or a Table and use
"experimental" pragma for dot overloading (in devel) or better using your own
operator like `.?` (which was already be planned to be as being part of the
compiler to allow: `foo.?bar` being equal to `foo[bar]` afair :)
Is this possible in nim?
An example of what I mean:
type
test* = object
var t = test()
var t.name = "kek" #This would fail to compile
@zahary thanks, I'll take a look.
@jcosborn I see. Let me think about it.
@andrea I'll check how static[int] is implemented (I can imagine that `3` is
encoded in the type).
I've started implementing this myself and I must apologise to the community for
leaving this unfinished for so long.
The first working bits can be seen here:
[https://github.com/nim-lang/Nim/blob/daae20e68c6b354cb09e842b742b7167245c91db/tests/concepts/tstackconcept.nim](https://github.com/nim-la
In the case of `proc f(x: Has[seq[any]])`, could you first try matching against
the generic `Has[T]`, let the concept body define `T`, then extract its value
and compare that against `seq[any]` to see if it matches? At that point if the
type constraint was `Has[seq[S]]` you could match to bind `
@mora `static[int]` itself is a type, but the generic type `M` in `Modulo[M]`
is a _particular_ static int which is known at compile time, say 3.
Hence one could instantiate a concrete type `Modulo[3]` which is a
specialization of the generic type `Modulo[M]`. The type `static[int]` would
appea
I think that `type T = ...` and `... is T` has a separate meaning. In my
example you could write `proc f(x: Has[seq[any]])`, which I don't know how to
resolve with `=`.
I understand that `static[int]` is useful, and thanks for the example (I've
seen that you have some open github issues with `s
@mora I don't see how your example would not work @jcosborn syntax:
type Has[T] = concept c
type T = type(g.gimme())
Then `T` is determined and one could treat it as a concrete type in subsequent
statements (i.e. - when another `T` appears, it must be the same)
About `st
Yes, this would be natural and we could support static values. However, there
is a case, where `T` needs to be injected. Based on Andrea's example, imagine
that you would like to have
type HasFloat = concept c
c.gimme() is float
type HasInt = concept c
c.gimme() is
@jcosborn I'm happy to implement anything which works & looks nice on some
basic examples.
By the way, I'm making small progress :)
> Are you sure you need both a server and a client for this? Yep. Here's the
> Google API auth routine:
1\. Have a server running on some host; this host should be provided to Google
during in the next step.
2\. Generate a URL to the user consent form and let the user open it.
3\. When the use
Sorry to answer my own question. I don't think MS Windows can subclass a
control just by changing its GWL_WNDPROC and registering a new Window Class.
Once I created a BUTTON object and changed its GWL_WNDPROC, then the object
behaved like a subclass object - very strange - I guess because MS Win
@OderWat Thank you for that!
I think I fixed that problem. See this
[PR](https://github.com/nim-lang/Nim/pull/4530/files) may be fixed in Nim devel
soon, if Araq does not tell me I did everything wrong... again :P
EDIT: As I already knew .. but this
[PR](https://github.com/nim-lang/Nim/pull/4531) probably makes it and fixe
I don't know if this helps, but wouldn't
type Container[T] = concept c
type T = type(get(c, 0))
be more natural? Plus we could extend it to allow static parameters
type Container[N,T] = concept c
const N = c.len
type T = type(get(c, 0))
Will I get in trouble for saying:
**_MySQL sucks, use PostgreSQL_** :P
I had used this before.. and this correctly shows the NULL values for the
example which crashes in the higher level case. I don't yet see how that is
happening :)
import strutils, os
# NOTE: Some versions of the nim library have the wrong size for TFIELDS
import mysql
There seems to be a compiler problem probably.
When I rewrite db_mysql like this:
iterator instantRows*(db: DbConn; columns: var DbColumns; query: SqlQuery;
args: varargs[string, `$`]): InstantRow =
## Same as fastRows but returns a handle that can be
EDIT: Not need to post your table. I can reproduce it :) funny.
@OderWat There is no difference in the length. The data is there it's just NULL
and for some reason that isn't being caught when I try to reference the index.
Well then check the index against `x.len`. x uses the InstantRow type which
uses the cstringArray type which has no boundscheck. I wonder how to reproduce
your problem though as there should never be a difference in x.len and dbC.len
imho.
@OderWat SIGSEGV: Illegal storage access. (Attempt to read from nil?) Results
in the same error. Already tried that actually.
I think you want this:
for idx, column in dbC:
row[column.name] = if x[idx] == nil: "none" else: x[idx]
30 matches
Mail list logo