Re: 'withfile' function implementation

2011-12-16 Thread Tim Murphy
Just a quick comment on this.

I looked at the implementation and it seems like a different name
would suit this function - e.g. writefile.  It basically writes text
from it's arguments out to a file.

The idea of a function called withfile seems hard to actually
implement - I'm not sure how one might even do it.  It would be like a
special kind of $(eval), I think.  The output file would be open while
the contents were being evaluated and closed when they finished.
Within this evaluation, any calls to $(write filehandle,) would
happen to the file.  I think this is a pretty hard thing to do and
although I love the (to me) elegance of it, it's a bit harder to
implement and the function you have provided is more than good enough
for the situations that I've needed so far.

I think that a withfile would come into it's own when you  could put
it around a giant makefile:
$(withffile fh,log.out,
include hugemakefile.mk
)

Since you would open and close the file only once rather than
repeatedly and this might be a good thing for parse speed.
But I suspect that this form could have performance, memory etc
implications that might be undesirable because of the need to load and
store a complete copy of the makefile in memory and then evaluate it.

Perhaps I will get a chance to submit some actual code one day when I
can sort out open source contributions with my employer.

In the meantime:

$(writefile filename,value)
$(appendfile filename,value)

would probably be quite nice and they don't absolutely demand that one
use the C library mode flags (w,w+,a etc). This is one thing that
Paul didn't like from the previous suggestions.

Regards,

Tim

On 15 December 2011 23:13, Lawrence Ibarria libar...@nvidia.com wrote:
 This is a rather simple path that implements a very simplified version of
 what Tim suggested in his message of Sept 25th
 (https://lists.gnu.org/archive/html/bug-make/2011-09/msg00044.html ).



 Paul, what do you think? I’d rather not try to do everything, just focus on
 one thing. I am not sure how much safety checks play a role inside make.



   -- Lawrence



 
 This email message is for the sole use of the intended recipient(s) and may
 contain confidential information.  Any unauthorized review, use, disclosure
 or distribution is prohibited.  If you are not the intended recipient,
 please contact the sender by reply email and destroy all copies of the
 original message.
 



-- 
You could help some brave and decent people to have access to
uncensored news by making a donation at:

http://www.thezimbabwean.co.uk/friends/

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: 'withfile' function implementation

2011-12-16 Thread Paul Smith
On Fri, 2011-12-16 at 12:41 +, Tim Murphy wrote:
 I looked at the implementation and it seems like a different name
 would suit this function - e.g. writefile.  It basically writes text
 from it's arguments out to a file.

Thanks all; I'll take a look.

-- 
---
 Paul D. Smith psm...@gnu.org  Find some GNU make tips at:
 http://www.gnu.org  http://make.mad-scientist.net
 Please remain calm...I may be mad, but I am a professional. --Mad Scientist


___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: 'withfile' function implementation

2011-12-16 Thread David Boyce
On Fri, Dec 16, 2011 at 7:41 AM, Tim Murphy tnmur...@gmail.com wrote:
 would probably be quite nice and they don't absolutely demand that one
 use the C library mode flags (w,w+,a etc). This is one thing that
 Paul didn't like from the previous suggestions.

A bit of a sidetrack, but I don't agree with the logic here. The
notion that r, w, and a stand for read, write, and append
did not originate with the C stdio library. One could make a case
against these mnemonics on grounds of English-centrism but
realistically English is the lingua franca and GNU make (patsubst,
--keep-going) is already thoroughly Anglicized, for better or worse.
And + has a truly international mnemonic value.

So: I have no particular attitude about which implementation is
chosen, but being skeptical of [rwa+] simply because fopen borrowed
from the same dictionary makes no sense to me. People familiar with
fopen will enjoy the symmetry, others will still see the common sense
in it.

-David Boyce

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make