Replies: 5 comments 13 replies
-
Done some searching in the code for similar hacks around c++ nimskull/compiler/sem/transf.nim Lines 448 to 453 in f62f5b9 nimskull/compiler/sem/semexprs.nim Lines 769 to 773 in f62f5b9 Inheritance is implemented differently between C and C++ backends - C uses composition, C++ uses native inheritance. This might've been theoretically useful if nim allowed properly interfacing with methods of the base objects (overriding them), but that's not implemented. nimskull/compiler/backend/ccgexprs.nim Line 838 in f62f5b9 C++ code vs C code for the same object definition // C++
struct tyObject_Main__PYvVJIOD0tjHqPPO9aT7bjw : public RootObj {
NI field;
};
struct tyObject_Derive__IW5bJ7hrVb5ctgr0HLGk8A : public tyObject_Main__PYvVJIOD0tjHqPPO9aT7bjw {}; // C
struct tyObject_Main__PYvVJIOD0tjHqPPO9aT7bjw {
RootObj Sup;
NI field;
};
struct tyObject_Derive__IW5bJ7hrVb5ctgr0HLGk8A {
tyObject_Main__PYvVJIOD0tjHqPPO9aT7bjw Sup;
}; Has to generate different expressions when accessing fields, different methods of passing object procedure that accepts parent object. var de = Derive(field: 12)
echo de
proc takesDe(a: var Main) =
discard
takesDe(de) de.Sup.field = ((NI)12);
colontmpD_ = dollar__file_195((&de));
if (NIM_UNLIKELY(*nimErr_)) goto LA5_;
T6_[0] = colontmpD_;
echoBinSafe(T6_, 1);
takesDe_file_220((&de.Sup)); de.field = ((NI)12);
colontmpD_ = dollar__file_195((&de));
T7_[0] = colontmpD_;
echoBinSafe(T7_, 1);
takesDe_file_220(de); |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@SolitudeSF commented that removal of the for loop macro was unfortunate as it's useful for them. Starting a thread here to capture their thinking so it can be referenced again in the future. @SolitudeSF could you share your thoughts with a reply to this comment? thank you |
Beta Was this translation helpful? Give feedback.
-
So, what's the "better way" of implementing the following functionality: import foreach
let a = [1, 2, 3]
foreach n in a.items of int:
echo n, " is an int" or import json
import foreach
let j = %* {
"one": 1,
"two": "2",
}
foreach k, v in j.pairs of string and JsonNode:
echo k, " is a string"
echo v, " is a JsonNode" (more examples at https://github.com/disruptek/foreach) |
Beta Was this translation helpful? Give feedback.
-
I don't know what any of that means to the user. We users were able to use Are you saying the right solution is to write AFAICT, this "gap" only exists because you removed the functionality without offering a replacement. What was the implementation blocking, anyway? |
Beta Was this translation helpful? Give feedback.
-
Project to Track this Work: https://github.com/orgs/nim-works/projects/5/views/1
I'm making a list of things that need to be removed in order for us to make progress with language development. Notice, I didn't say compiler development, because I want to dispell any notion of this having anything to do with Nim -- this last point isn't up for debate. The rest, however is.
What follows is a list of things to be disabled/removed, at least temporarily, in order to make progress:
That's it for now, I'll add more the the above list based on the discussion, if any, that ensues.
Will we bring some or all of these back, likely in some form or another, but it's daunting making progress with just piles of mistakes layered on top of each other.
Details:
ObjectiveC Support
It's pretty much untested and I'd rather spare CI cycles and simplify our test matrix than take on more scope.
Code Reordering (removed)
It doesn't work and adds a lot of complexity before we have the prerequisite capabilities to support it.
Hot Code Reloading
This hurts, but beyond the slow test, complexities in testament, in the backend, and a number of other places it's yet another thing that slows down development. The compiler having an understanding of packages and modules, and moreover versions/lineage of these is a must via IC before we can correctly implement it. In the mean time, it's another set of gotchas.
Parallel and Spawn (removed)
This is implemented in the cgen backend, the fact that it creates a cyclic dependency between sem and the backend should be reason alone to kill it with fire. Not to mention this is an experimental feature that's completely mismatched with how NimSkull should approach concurrency and parallelism (hint: structured and built upon CPS).
Disallow pragmas on nkVarTuple idents (removed)
This is plain broken for all sorts of pragmas, resulting in nil pointer issues in the compiler, macro/template pragmas can't return correct AST under any circumstance, built-in pragmas like
compileTime
don't work, etc...C++ Backend
semExprs
hack was removed in sem (cpp: remove cpp addr/deref handling in sem #290) and much of the necessary fixes were made in cpp: fixvar
parameter regression #294.Beta Was this translation helpful? Give feedback.
All reactions