Closed TimDeve closed 1 year ago
Isn’t this a case for --eval-postload
?
I guess that would work for (Debug.sanitize-addresses)
but not for the other usages.
It's not possible to def a String for example:
$ echo "(defn main [] (IO.println &wow))" > main.carp
$ carp -x --log-memory --eval-preload '(def wow @"string")' main.carp
I can’t find any implementation for the interface `copy` of type (Fn [(Ref String r3)] String) at line 1, column 10 in 'Preload'.
None of the possibilities have the correct signature:
Array.copy : (Fn [(Ref (Array a) q)] (Array a))
Pointer.copy : (Fn [(Ref (Ptr p) q)] (Ptr p))
Box.copy : (Fn [(Ref (Box t) q)] (Box t))
Function.Arity0.copy : (Fn [(Ref (Fn [] z) q)] a)
Function.Arity1.copy : (Fn [(Ref (Fn [d] z) q)] a)
Function.Arity2.copy : (Fn [(Ref (Fn [d, e] z) q)] a)
Function.Arity3.copy : (Fn [(Ref (Fn [d, e, f] z) q)] a)
Function.Arity4.copy : (Fn [(Ref (Fn [d, e, f, g] z) q)] a)
Function.Arity5.copy : (Fn [(Ref (Fn [d, e, f, g, h] z) q)] a)
Function.Arity6.copy : (Fn [(Ref (Fn [d, e, f, g, h, i] z) q)] a)
Function.Arity7.copy : (Fn [(Ref (Fn [d, e, f, g, h, i, j] z) q)] a)
Function.Arity8.copy : (Fn [(Ref (Fn [d, e, f, g, h, i, j, k] z) q)] a)
Function.Arity9.copy : (Fn [(Ref (Fn [d, e, f, g, h, i, j, k, l] z) q)] a) at Preload:1:2.
Traceback:
(def wow (copy "string")) at Preload:1:1.
huh, whatever changed the behavior is not obvious. the actual pre/post impl haven't changed at all since they were first implemented, as far as I can tell
might need to do a git bisect
and check the behavior at each stage. presumably we can use the commit that introduced the feature as the good commit: 6bce3b1e
What has changed is the order in which things are ran:
it used to be:
loadFilesOnce startingContext coreModulesToLoad
>>= load [carpProfile | hasProfile]
>>= execStrs "Preload" preloads
>>= load argFilesToLoad
>>= execStrs "Postload" postloads
And now is
pure startingContext
>>= load [carpProfile | hasProfile && profile]
>>= execStrs "Preload" preloads
>>= loadOnce coreModulesToLoad
>>= load argFilesToLoad
>>= execStrs "Postload" postloads
But I also can’t remember why.
As for It's not possible to def a String for example:
, in your example you use --eval-preload
. Shouldn’t it be postload
instead?
Postload runs after the user files so you can't inject things to be used by these files.
But I also can’t remember why.
Git blame says the last changes were two years ago and that's a formatting commit, clearly I haven't used preload in a while then.
I'm just gonna close this, it seems that preload use to behave differently but if that was two years ago then it doesn't feel that that this is a useful.
It used to be possible to access things from Core in --eval-preload. A useful alias I have is:
but this now produces an error:
Using preload without refering to things from Core still works:
But anything from Core fails:
It's possible to work-around that by loading Core manually: