eclipse-archived / ceylon-web-ide-backend

The Ceylon Web IDE
http://try.ceylon-lang.org/
Apache License 2.0
25 stars 11 forks source link

Example 10 "Enumerations" broken #60

Closed lucaswerkmeister closed 10 years ago

lucaswerkmeister commented 10 years ago

Due to #58, example 10 is broken. In #59, I worked around the same error by just removing the enumerated type specification, but since this example is supposed to showcase enumerated types, I don’t think we can do that here.

I guess we just have to bite the bullet and change the comment to something like this:

// Object enumerations are also possible;
// however, they're currently broken in the web IDE.
// For more information, see issue #58 on Github
// (link to Github is under the output field).
abstract class Color(name) /* of red | green | blue */ {

I’m not really happy with that particular phrasing though, because I fear that people may think that this is a limitation of the JS backend instead of the web IDE.

quintesse commented 10 years ago

Ok, for now this is somewhat of a hack. When you add the comment //$ webrun_full_script to the top of the source the web runner won't wrap the code in a method anymore. You'll need to add the void run_script() entry point yourself. This way works best with the current setup because it allows us to keep the simple 1-source-is-everything system we have now (examples are 1 source file and code in the database is also a single source entry). At some point in the future we can hide this behind a nicer interface (an "advanced" checkbox or whatever) but for now this will do, it at least shows the code as it is meant to be shown.

quintesse commented 10 years ago

Btw this is live at http://trybeta-ceylon.rhcloud.com/

lucaswerkmeister commented 10 years ago

And if someone wants to write enumerated types themselves? I think this needs a bit more documentation; either above Color (where I added my "it's broken" comment) or perhaps when the error message shows up ("this object isn't actually toplevel because the code is wrapped in a run function; use ... to fix this.")

But thanks for the solution, even if it's a hack!

----- Ursprüngliche Nachricht ----- Von: "Tako Schotanus" notifications@github.com Gesendet: ‎20.‎05.‎2014 13:43 An: "ceylon/ceylon-web-ide-backend" ceylon-web-ide-backend@noreply.github.com Cc: "Lucas Werkmeister" mail@lucaswerkmeister.de Betreff: Re: [ceylon-web-ide-backend] Example 10 "Enumerations" broken (#60)

Ok, for now this is somewhat of a hack. When you add the comment //$ webrun_full_script to the top of the source the web runner won't wrap the code in a method anymore. You'll need to add the void run_script() entry point yourself. This way works best with the current setup because it allows us to keep the simple 1-source-is-everything system we have now (examples are 1 source file and code in the database is also a single source entry). At some point in the future we can hide this behind a nicer interface (an "advanced" checkbox or whatever) but for now this will do, it at least shows the code as it is meant to be shown. — Reply to this email directly or view it on GitHub.

quintesse commented 10 years ago

I opened a new issue (#65) for improvements to the GUI for this. I don't think special error messages will do the trick because they come directly from the typechecker and we'd have to do some more hackery to detect them and change or add to them (and keep that up-to-date if at some time the error message changes etc).

A possibility might be for example to make it visually obvious that you're writing the code in a toplevel function (maybe by adding void run_script() { above the editor box and } below it. Or maybe the editor can even be forced to have an uneditable first and last line, I don't know).