From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Grover Newsgroups: gmane.lisp.guile.user Subject: Re: mkstemp strange behavior Date: Wed, 10 Aug 2005 13:54:31 -0400 Message-ID: <42FA3F57.6090605@mail.msen.com> References: <20050810172526.GA7101@igbt.sel.eesc.usp.br> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2046204335==" X-Trace: sea.gmane.org 1123696939 22026 80.91.229.2 (10 Aug 2005 18:02:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 10 Aug 2005 18:02:19 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Aug 10 20:02:17 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E2us8-00071D-Qx for guile-user@m.gmane.org; Wed, 10 Aug 2005 20:00:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E2uvG-0005mw-C5 for guile-user@m.gmane.org; Wed, 10 Aug 2005 14:03:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E2utr-0005H7-IB for guile-user@gnu.org; Wed, 10 Aug 2005 14:01:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E2utn-0005DH-9b for guile-user@gnu.org; Wed, 10 Aug 2005 14:01:56 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E2utk-0005BB-SH for guile-user@gnu.org; Wed, 10 Aug 2005 14:01:52 -0400 Original-Received: from [148.59.80.48] (helo=ww8.msen.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1E2v0x-000341-No for guile-user@gnu.org; Wed, 10 Aug 2005 14:09:19 -0400 X-Sent-To: Original-Received: from [192.168.1.220] (pool-151-196-115-140.balt.east.verizon.net [151.196.115.140]) (authenticated bits=0) by ww8.msen.com (8.13.4/8.13.4) with ESMTP id j7AHsbCS005859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 10 Aug 2005 13:54:38 -0400 (EDT) (envelope-from awgrover@mail.msen.com) User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en Original-To: guile-user@gnu.org In-Reply-To: <20050810172526.GA7101@igbt.sel.eesc.usp.br> X-Enigmail-Version: 0.92.0.0 OpenPGP: id=5074AF60; url= X-Milter: Spamilter (Reciever: ww8.msen.com; Sender-ip: 151.196.115.140; Sender-helo: [192.168.1.220]; ) 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:4681 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:4681 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --===============2046204335== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC447A243EF1B359A895C0CAC" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC447A243EF1B359A895C0CAC Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I ran into this too. My reasoning was something like: 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. Mkstemp modifies the (one and only) string the first time. If you force the value to be computed at exec time, the problem should go away: (string-append "" "/tmp/XXXXXX"). You could test my theory by something like: (define (test) (let ((filename "/tmp/XXXXXX")) filename)) (display (eq? (test) (test))) Which yields #t for me. And, (eq? "/tmp/XXXXXX" "/tmp/XXXXXX") yields #f, for comparison. 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 ha= ve no > success... I mkstemp! is getting me confused. It alters original string= , 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 se= cond > 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 Alan Grover awgrover@mail.msen.com +1.734.476.0969 --------------enigC447A243EF1B359A895C0CAC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFC+j9cbLLh2VB0r2ARAgV1AKCU2LKJtesMxO9OtXPjdKJG/rymfQCdHLoT vUOCn+FJJ/VdGjlfc7ynmUw= =blRQ -----END PGP SIGNATURE----- --------------enigC447A243EF1B359A895C0CAC-- --===============2046204335== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user --===============2046204335==--