php-mode icon indicating copy to clipboard operation
php-mode copied to clipboard

Don't require byte-compile

Open andreas-roehler opened this issue 9 years ago • 9 comments

Having a look into Makefile, it seems there is no option how to avoid byte-compiling.

However, compiling Emacs Lisp files is optional. Avoiding it has advantages: no mistake when developing, because older compiled files was taken, not the changes source etc.

OTOH loss of speed when running from source IMO is to neglect. Should Emacs be slow, it's a matter of design often - circular calls for example.

andreas-roehler avatar Jul 29 '15 06:07 andreas-roehler

Having a look into Makefile, it seems there is no option how to avoid byte-compiling.

That's true. If we have a make target which does not byte-compile the code then what would that target do? Right now make test byte-compiles everything, so maybe that target could benefit from a rule which tests the uncompiled sources since they could have changes not in the compiled versions as you point out. Are there other useful targets we could add to the Makefile which should avoid byte-compiling?

ejmr avatar Jul 29 '15 06:07 ejmr

Am 29.07.2015 um 08:43 schrieb Eric James Michael Ritz:

Having a look into Makefile, it seems there is no option how to
avoid byte-compiling.

That's true. If we have a make target which does not byte-compile the code then what would that target do?

Well, Makefile is a universal knife, so it's up to you making use of it.

Right now |make test| byte-compiles everything, so maybe that target could benefit from a rule which tests the uncompiled sources since they could have changes not in the compiled versions as you point out. Are there other useful targets we could add to the Makefile which should avoid byte-compiling?

— Reply to this email directly or view it on GitHub https://github.com/ejmr/php-mode/issues/261#issuecomment-125859206.

Suggest to implement a

make compile

for those who want it.

Otherwise don't compile anything.

andreas-roehler avatar Jul 29 '15 07:07 andreas-roehler

Having a make compile sounds like a good idea to me, if only to be explicit. But then I'm not sure what simply make should do by default. If the user doesn't want to byte-compile the files then they don't need to run 'make' at all, which makes me want to turn make compile into the default target.

ejmr avatar Jul 29 '15 07:07 ejmr

Am 29.07.2015 um 09:52 schrieb Eric James Michael Ritz:

Having a |make compile| sounds like a good idea to me, if only to be explicit. But then I'm not sure what simply |make| should do by default. If the user doesn't want to byte-compile the files then they don't need to run 'make' at all, which makes me want to turn |make compile| into the default target.

— Reply to this email directly or view it on GitHub https://github.com/ejmr/php-mode/issues/261#issuecomment-125873439.

Maybe default just gives a kind of help-message WRT available arguments?

In any case "make test" needs also being de-coupled from compile.

andreas-roehler avatar Jul 29 '15 08:07 andreas-roehler

I expect most people install PHP Mode through MELPA via Emacs' package manager, and that compiles the *.el files automatically, which is another reason I think make by default is right to byte-compile everything. Or I guess to put it another way, I don't see a major advantage to having the Makefile not compile in this situation.

In any case "make test" needs also being de-coupled from compile.

Why? I'm not opposed to the idea, but I also don't see what we would gain. Compiling the files before testing isn't costing us a lot of time. Nor does it prevent developers from running ERT within Emacs itself to test their changes without byte-compiling.

ejmr avatar Jul 29 '15 09:07 ejmr

Am 29.07.2015 um 11:12 schrieb Eric James Michael Ritz:

I expect most people install PHP Mode through MELPA via Emacs' package manager, and that compiles the |*.el| files automatically, which is another reason I think |make| by default is right to byte-compile everything. Or I guess to put it another way, I don't see a major advantage to having the Makefile not compile in this situation.

In any case "make test" needs also being de-coupled from compile.

Why? I'm not opposed to the idea, but I also don't see what we would gain. Compiling the files before testing isn't costing us a lot of time. Nor does it prevent developers from running ERT within Emacs itself to test their changes without byte-compiling.

— Reply to this email directly or view it on GitHub https://github.com/ejmr/php-mode/issues/261#issuecomment-125887969.

If people start to hack Emacs, a common error is to forget the "*.elc" file is re-loaded, not the changed source.

Also there are some subtle diffs WRT behaviour of compiled code, notably WRT macros. Ert as not suitable for all needed cases because of that, nor is batch-mode.

Well, not a big thing after all, there is still

find . -type f -name ".elc" | sed 's/(.)/rm \1/g' | sh

andreas-roehler avatar Jul 29 '15 09:07 andreas-roehler

Also there are some subtle diffs WRT behaviour of compiled code, notably WRT macros.

Good point. With regard to byte-compiling (or not), the effects on macros is something we will have to carefully keep in mind. Right now only the test suite makes any major use of macros, but this is still a good reminder.

ejmr avatar Jul 29 '15 22:07 ejmr

I don't agree with Andreas's reasoning, but it would be nice to decouple compiling and testing to enable mounting the source directory read-only to a container or something like that. (automake has this nice feature "VPATH builds" where source and build trees are totally separated, but that would probably be overzealous :-).) I think testing that php-mode.el and php-mode-test.el can be compiled (without errors or warnings) is necessary, but we don't need the resulting files. It should be possible to use byte-compile-dest-file-function to direct the output to /dev/null.

scfc avatar Sep 09 '17 22:09 scfc

On second thought, discarding the output files would mean that the issues with macros and compilation that Andreas alluded to are never tested, i. e. while the test suite would always read php-mode.el, users in general would deal with php-mode.elc which might exhibit subtly different behaviour. So my use case would better be handled by byte-compiling to and reading from a temporary directory, and I propose to close this issue as I consider byte-compiling necessary for development.

scfc avatar Sep 09 '17 23:09 scfc

Please open a PR if you're interested in testing without byte-compiling. Thank you everyone.

zonuexe avatar Oct 27 '22 16:10 zonuexe