> From: Mark H Weaver <m...@netris.org> > To: guile-devel@gnu.org > Cc: Michael Gran <spk...@yahoo.com> > Sent: Sunday, January 13, 2013 10:25 AM > Subject: Scanning for coding declarations in all files (not just source) > Hi Mark,
> I just discovered that Guile is scanning for coding declarations in > *all* files opened with 'open-file', not just source files. True > For source files, we are scanning for coding declarations twice: once > when when the file is opened, and a second time when 'compile-file' or > 'primitive-load' explicitly scans for it. If there was a reason for scanning the coding twice, I don't recall it. > > The relevant commit is 211683cc5c99542dfb6e2a33f7cb8c1f9abbc702. > I was unable to find any discussion of this on guile-devel. > > I don't like this. I don't want 'open-file' to second-guess the > encoding I have asked for in my program, based on data in the file. > Also, the manual is misleading. Section 6.17.8 gives the impression > that the scanning is only done for source files. > > What do other people think? Opening a file that contains a coding declaration using an encoding other than binary or the coding declared in the file seems like it would be something of a corner case. So, IMHO it makes sense that opening a file using its self-declared encoding should be the simple case, and that opening a text file in a different (non-binary) text encoding should be the more complicated case, in a API sense. There are also obscure possibilities to consider, like reading code from a file or pipe into a string, and then eval-ing the string. But, I can see your point, though. Guile does seem to be having a tough time deciding how automatic or manual string encoding should be. So, whatever makes people happy. -Mike