Skip to content
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

Support multipe modules on run.dlang.io #656

Open
JinShil opened this issue Jan 29, 2018 · 12 comments
Open

Support multipe modules on run.dlang.io #656

JinShil opened this issue Jan 29, 2018 · 12 comments

Comments

@JinShil
Copy link
Contributor

JinShil commented Jan 29, 2018

This is a feature request to add support to run.dlang.io for editing/compiling multiple modules/files.

@wilzbach
Copy link
Member

wilzbach commented Jan 29, 2018

Thanks a lot for the request, Mike!

However, I'm inclined to close it as a WONTFIX.
Here are my thoughts

  • it's would be a lot of work to change the frontend and backend to do so

  • it would be hard to support this in the frontend without adding visual baggage

  • run.dlang.io doesn't try to be an IDE, just a convenient way to play with D code

  • there aren't that many advantages I see of having multiple files - except for (1) testing and showing how module imports work, (2) using advanced D features like string imports, (3) find/test import bugs in DMD and (4) if your file is so large that it needs to be split up into multiple modules for better visibility

  • (1) there are a few examples on the D specification where this would be nice, but apart from that I have never found the need

  • (2) instead of `import("myFile.txt") the text can be inlined. D supports delimited strings.

  • (3): there's active WIP to fix the import bugs

  • (4): it's the active won't fix category

  • there are existing, sophisticated web IDEs

  • for "bigger" things I personally prefer to have my vim ...

Please see my NG thread about the D boilerplate template. It can be used as a template for the awesome WebIDE Cloud9 - simply use https://github.com/wilzbach/d-bootstrap as a template (or clone it in an existing workspace), hit make and your D code runs automagically.
Imho we will never be as good as Cloud9 which has an entire development team and can utilize the AWS infrastructure directly.

What is your use case?

@JinShil
Copy link
Contributor Author

JinShil commented Jan 29, 2018

My use case is for sharing code and ideas with others. So, for example, I could post an example to illustrate a minimal runtime with an object.d and a main.d, and readers can try the example immediately. Or to illustrate concepts such as visibility from one module to another. This can be useful for demonstrating features and bugs on the forum or in Bugzilla. I also think there are a use cases in the documentation where it would be useful to teach concepts.

Perhaps I could make use of Cloud9 for such things; I've never tried.

I will say that this is a luxury and not a necessity. It's your call. No hard feelings if you choose not to implement it, I promise.

@wilzbach
Copy link
Member

Well, I agree that's "generally useful", but not many click & run platforms I know of/have used, support this:

Actually https://godbolt.org is the online platform that supports this that comes to my mind and it's windowing framework looks rather complicated.

Perhaps I could make use of Cloud9 for such things; I've never tried.

If you use the micro instances, the first year is for free. Though I think you need to explicitly add people to the workspace

So, for example, I could post an example to illustrate a minimal runtime with an object.d and a main.d, and readers can try the example immediately.

That's actually a good use case - think ... we could "hack" that in though. We already support import from GH's gist, so in theory something similar to DUB single file format could work, e.g.

# add object.d from https://gist.github.com/anonymous/451a0fb778381b11ed80078d5e0b6653
void main() {

}

Well that would be a simple start and it's left optional whether the frontend actually needs to support multiple files.

Well if you or someone else want to take a go at this, it would require the following adjustments:

  1. Allow to pass multiple files to the Docker container https://github.com/dlang-tour/core-exec (maybe simply as additional arguments). Currently STDIN can be passed as $2, but an environment variable like DOCKER_COLOR or DOCKER_FLAGS would work too.
  2. Modify the ExecProviders to accept multiple sources: https://github.com/dlang-tour/core/blob/master/source/exec/iexecprovider.d
  3. Modify the invocation of the docker image to pass on the additional files https://github.com/dlang-tour/core/blob/master/source/exec/docker.d#L133
  4. Modify the REST API to accept multiple files: https://github.com/dlang-tour/core/blob/master/source/rest/apiv1.d

As mentioned I don't need this, so I won't work on this in the foreseeable future, but I'm happy to merge PRs.

@wilzbach
Copy link
Member

Initial HAR support is now live:
https://run.dlang.io/is/ZHm2Xe

It's still experimental and most of the buttons don't work, but it should be enough to judge whether it's useful in this form.

And also we can start integrating it into the DTour + dlang.org where these buttons don't exist anyways.

@JinShil
Copy link
Contributor Author

JinShil commented Feb 21, 2018

Tried a minimal runtime test with this: https://run.dlang.io/is/rrhgJL

object.Exception@rdmd.d(105): Option -o- currently not supported by rdmd

I'm not sure what that means.

@wilzbach
Copy link
Member

I'm not sure what that means.

I initially tried to use rdmd for multiple files because -run is terribly broken (see e.g. dlang/dmd#7927), but well it turns out rdmd isn't a good choice for this either.

Anyhow I just pushed a fix and it should be deployed in a few minutes:

dlang-tour/core-exec#36

@wilzbach
Copy link
Member

It works now: https://run.dlang.io/is/UwoLSC

@JinShil
Copy link
Contributor Author

JinShil commented Feb 21, 2018

So cool!. Thanks. I'm OK to close this issue if you consider it solved.

@JinShil
Copy link
Contributor Author

JinShil commented Feb 21, 2018

Ah wait!. This gave me a strange error: https://run.dlang.io/is/gHkwbJ

/sandbox/object.d(1): Error: found `EOF` when expecting `}` following compound statement

@wilzbach
Copy link
Member

Hmm it goes away if I remove the comment: https://run.dlang.io/is/7k0KLk

@wilzbach
Copy link
Member

For reference, this was a bug in har.
An updated version of har has been deployed: https://run.dlang.io/is/KBOVEb

@WebFreak001
Copy link
Member

the main function doesn't seem to be found when using HAR right now.

However if you add -i -run app.d to the dmd arguments, you can work around this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants