New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#cd compiler directive is ignored when #load-ing the script #1392
Comments
@matthid As things stand, this is by design - like some of the other directives, Supporting it in some form might make sense, though really we should just support something like what you mention:
|
@dsyme I assumed something like that, but what do you think of the inconsistency with FCS? IE it uses '#load' for it's EvalScript functionality, this is surprising at the very least. As well as scripts behave differently between executing in fsi and '#load' ing them. This is really unexpected and shouldn't exist (see all the related other bugs/quirks). Is it possible to just make '#load' do the same as fsi and get rid of all the quirks (including this) even if it means to make things possible which are not specified/documented? |
One more note about the other syntax: Currently its really simple for tools like Fake to calculate a hash. We just follow all '#load' links and calculate a hash for all contents. This might be (maybe?) more difficult to do with the '+'. At least it breaks constructs like that (I think we can easily fix it in fake, this is just to show that others might depend on this somehow). |
@matthid I think you should use FCS's EvalInteraction instead of EvalScript to get consistency? We'll aim to take a look at the other inconsistencies one by one (they aren't easy to fix though...) |
I think FCS should do that in EvalScript... Not exactly easy is perfect to start. I would try to take a look. Good would be a general guide at how you ideally would like to solve that. So you agree that |
In the F# scripting model there is a distinction between
For (1), the DLL is referenced but the initialization code is not forced eagerly. For (2), the documentation for
For these components:
For (3) , "interaction"s:
|
@dsyme First thank you for the detailed answer! Second: I'm really sorry for my ignorance here. I (kind of) understand the current split. What I'm generally asking here if it makes any sense (from a non-technical view). IE are there any reasons to do this besides technical ones? This design really leads to a lot of situations considered as bugs by most people (when it is in fact "working as designed"). Also I don't understand how that fits with this simple sample:
So you consider this as bug? Maybe there should be another way of loading scripts interactively? Wouldn't that be even more confusing for users? This may look like we are drifting away from this issue, but ultimately I would like to provide my help in implementing support for this scenario one way or another. IMHO Saying this is by design is not sufficient from an From a philosophical view: IMHO When you load a |
@matthid just for the specific case of compiling |
@smoothdeveloper Yeah I know. I just wanna hear @dsyme's opinion on the discrepancy. |
@matthid Initialization code for I've updated my comment above to include |
@matthid I'm still not sure why |
@dsyme Do you mean reading the script completely and using I still think this is the root cause for a lot of confusion, which is really not needed. I mean at least we should print a warning if interaction directives are ignored (and a link to this thread). Even better would of course be if it worked "as a user would expect". |
For anyone curious: See fsharp/fsharp-compiler-docs#621 You additionally should use the |
I agree |
When using
#load
preprocessor directives like#cd
are ignored.Repro steps
test.fsx
g/test.fsx/other.fsx
printfn "other.fsx"
fsi
#load "test.fsx"
Expected behavior
Actual behavior
Known workarounds
Currently none.
Related information
fsi
bundled with Visual Studio 2015 Update 3#load
behind the scenes (https://github.com/fsharp/FSharp.Compiler.Service/blob/master/src/fsharp/fsi/fsi.fs#L2139)Executing the file directly
fsi test.fsx
yields the expected output:
other.fsx
I used this originally because I cannot write something like
The text was updated successfully, but these errors were encountered: