Terminus-IMRC / gnumake-brainfuck

Brainfuck implementation in GNU Make
0 stars 0 forks source link

GNU make is chatty #1

Open rdebath opened 8 years ago

rdebath commented 8 years ago

I suggest you add a line like below somewhere to get rid of the error message

-:;@:

Otherwise, wow. I though eval looked like a good candidate but you beat be to it.

Terminus-IMRC commented 8 years ago

Thanks. But : command is not usable in Windows...

Terminus-IMRC commented 8 years ago

I'm planning to use GNU Make's Makefile-remaking function (c.f. https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html ) because eval'ing macro calls infinitely consumes memory too much. But it's not clear whether it can be done.

rdebath commented 8 years ago

Okay ... how about this ?

-:;@ #
Terminus-IMRC commented 8 years ago

To tell the truth, I don't have windows machines. Is it work in Windows?

rdebath commented 8 years ago

I just downloaded and installed the native compile from here onto a machine I can RDP to. Interestingly enough the code with the colon ie: -:;@: works nicely. I suspect it's interpreted as a label line in a batch file. The hash does NOT work; it's treated as a DOS command not a Makefile comment.

Actually, that make a lot of sense, as the : command in the Bourne shell and the DOS command processor both come from the old "Thompson Shell".

As for remaking makefiles ... it looks like it might work. I guess you'd have to define a state transition rule that reads a current makefile and creates a new one with one BF instruction executed (Maybe just one line that's "include"d). There is that $(file) command so you're not forced to use an external command to write to a file.

Terminus-IMRC commented 8 years ago

Thank you! That also make a sense in that ksh and csh/tcsh also treat : as a comment (✿╹◡╹)ノ. So I'll add the line to the Makefile.

Yes! I knew that GNU Make has $(file) macro. I'll test it.

Terminus-IMRC commented 7 years ago

It's too be late but I found that the remaking rule completely execs the next Make. In this case, variables are not reserved. So we must save variables to files. This is not so efficient.

Do loops by using $(eval)

Pros

Cons

Do loops by using remaking rules

Pros

Cons

Terminus-IMRC commented 7 years ago

This Makefile infinitely loops if TIME ≧ 1, but it doesn't loop if TIME < 1. It may be due to filesystems's time resolution...

$(info ** Remaking **)

TIME = 1

Makefile: FORCE
        touch $@
        sleep $(TIME)

.PHONY: FORCE
FORCE:
rdebath commented 7 years ago

Treating the same timestamp as "not out of date" is actually mandated by POSIX. It's also generally regarded as a good idea because on a modern system with sub-second timestamps they will only be the same if someone has explicitly set them or broken them by using a tool that has seconds only resolution. (eg: tar)

But, I seem to remember that it's actually a lot more complex than that, with some systems (even some versions of Linux) having weird timewarps below second resolution. So I don't see a brainfuck interpreter getting any changes in this area :grin: