From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "R. Mattes" Newsgroups: gmane.lisp.guile.user Subject: Re: mkstemp strange behavior Date: Wed, 10 Aug 2005 20:18:29 +0200 Organization: Seid Online Message-ID: <1123697910.15860.26.camel@hobbes.mh-freiburg.de> References: <20050810172526.GA7101@igbt.sel.eesc.usp.br> <42FA3F57.6090605@mail.msen.com> Reply-To: rm@seid-online.de NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1123780472 15981 80.91.229.2 (11 Aug 2005 17:14:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Aug 2005 17:14:32 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Aug 11 19:14:22 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E3GcI-0002y2-Sq for guile-user@m.gmane.org; Thu, 11 Aug 2005 19:13:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E3GfT-000309-FE for guile-user@m.gmane.org; Thu, 11 Aug 2005 13:16:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E2vKh-0002z3-SI for guile-user@gnu.org; Wed, 10 Aug 2005 14:29:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E2vKd-0002wV-J0 for guile-user@gnu.org; Wed, 10 Aug 2005 14:29:41 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E2vKc-0002tF-PA for guile-user@gnu.org; Wed, 10 Aug 2005 14:29:38 -0400 Original-Received: from [193.197.131.2] (helo=forte.mh-freiburg.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1E2vO5-0004mh-58 for guile-user@gnu.org; Wed, 10 Aug 2005 14:33:13 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by forte.mh-freiburg.de (Postfix) with ESMTP id 6C8D021F379; Wed, 10 Aug 2005 20:23:28 +0200 (MEST) Original-Received: from forte.mh-freiburg.de (localhost [127.0.0.1]) by localhost (AvMailGate-2.0.1.10) id 01276-26D09948; Wed, 10 Aug 2005 20:23:28 +0200 Original-Received: from hobbes.mh-freiburg.de (unknown [192.168.42.21]) by forte.mh-freiburg.de (Postfix) with ESMTP id E248521F379; Wed, 10 Aug 2005 20:23:27 +0200 (MEST) Original-To: Alan Grover In-Reply-To: <42FA3F57.6090605@mail.msen.com> X-Mailer: Evolution 2.2.1.1 X-AntiVirus: checked by AntiVir MailGate (version: 2.0.1.10; AVE: 6.31.1.0; VDF: 6.31.1.88; host: forte) X-Mailman-Approved-At: Thu, 11 Aug 2005 13:14:55 -0400 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:4684 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:4684 On Wed, 2005-08-10 at 13:54 -0400, Alan Grover wrote: > I ran into this too. My reasoning was something like: >=20 > The string, "/tmp/XXXXXX" is constructed at reader time. So, there is > exactly one string. The "let" creates a new variable each time you call > "test", but the variable is bound to the same string. Besides: string constants (i.e. "xxx" stuff) are _inmutable_ in scheme. > Mkstemp modifies the (one and only) string the first time. Yes, modifying a constant is not a good idea (and guile should croack=20 allready the first time). Just my 0.02$ =20 Ralf Mattes > If you force the value to be computed at exec time, the problem should > go away: (string-append "" "/tmp/XXXXXX"). >=20 > You could test my theory by something like: >=20 > (define (test) (let ((filename "/tmp/XXXXXX")) filename)) >=20 > (display (eq? (test) (test))) >=20 > Which yields #t for me. And, (eq? "/tmp/XXXXXX" "/tmp/XXXXXX") yields > #f, for comparison. >=20 > Jos=E9 Roberto B. de A. Monteiro wrote: > > Hello all! > >=20 > > I was trying to use mkstemp! in my program, instead of tmpnam, but I = have no > > success... I mkstemp! is getting me confused. It alters original stri= ng, so > > we can easely have the name of temporary file. > >=20 > > But, with following code, I suposed it would work, but it is reusing = an old > > string: > >=20 > > #!/usr/bin/guile \ > > -s > > !# > >=20 > > (define (test) > > (let ((filename "/tmp/XXXXXX") > > (tmp #f)) > > (format #t "before: filename=3D~A\n" filename) > > (set! tmp (mkstemp! filename)) > > (format #t "after : filename=3D~A\n" filename) > > (close tmp))) > > =20 > > (format #t "First call...\n") > > (test) > > (format #t "Second call...\n") > > (test) > > =20 > > And the result of this code is: > >=20 > > First call... > > before: filename=3D/tmp/XXXXXX > > after : filename=3D/tmp/HGLPtZ > > Second call... > > before: filename=3D/tmp/HGLPtZ > > ERROR: In procedure mkstemp!: > > ERROR: Invalid argument > >=20 > > I can not figure out why the string is not set to /tmp/XXXXXX in the = second > > call... > >=20 > > Some help!? > >=20 > > Regards > > Betoes > >=20 > >=20 > > _______________________________________________ > > Guile-user mailing list > > Guile-user@gnu.org > > http://lists.gnu.org/mailman/listinfo/guile-user > >=20 >=20 > _______________________________________________ > Guile-user mailing list > Guile-user@gnu.org > http://lists.gnu.org/mailman/listinfo/guile-user _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user