Split up primops.cc
#42
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#42
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Nearly every primop is defined in one file. Move them into different files.
I'm starting to tackle this, one question I have, some primops are define with lambda funtions :
but other define a
prim_*
function, where this function is not used anywhere else :It would be great to have a uniform way to define the primops, which one should we choose ?
Semi orthogonal, but to keep in mind while doing this refactoring: #359
(Also: of your two options, I personally slightly prefer option number 1. There might be exceptions where I find number 2 better though, e.g. when the implementation of the primop is complex and long.)
Right, I have an idea on how to do it but not sure how to implement it.
Each file
toto.cc
insrc/libexpr/primops
defines aPrimOp
structprimop_toto
and inprimops.cc
we have the functionEvalState::createBaseEnv
which will calladdPrimop(primop_toto)
for each primop.The complicated part I guess is to automatically extract the list of primops to initialize, or we can do it by hand, given that we don't add primops every week.
Yeah, I'd tend towards doing it by hand too, and the approach you're describing is what I was thinking about too. FWIW I'm not suggesting you have to take care of #359 along the way, but if you want to help that would be welcome!
I'll do it in the final commit of the chain I think, first I need to split everything ^^
we'll disagree and prefer option number 2 (explicit implentation functions) for reasons of indentation stacking being less bad in that case and clang-format still sometimes misformatting lambdas. for small primops like in the example it'll be absolutely fine, but a lot of them unfortunately aren't quite that tiny. proposed heuristic: if you want to add newlines to group things for clarity, make it a static function instead of a lambda?
unfortunately in your current attempt of one primop per file compile times have gone through the roof, +25% for splitting that one file. we can't in good conscience approve that, compile times are already far too long :/ maybe running iwyu over the final splits will undo this, but until we can find a way to undo it we'd rather have one file per topic (type support, interop formats, attrset functions, list functions, etc) :(
Soooo, do I need to rewrite the whole chain or can I fuse some files at the end of the chain ?
that depends. if you're going to rebase the chain we'd kindly ask you to abandon and reorder+squash instead, if you're not going to rebase fusing at the end should be fine. but we should absolutely avoid another DoS situation on ci :)