From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] for strports.c: scm_c_eval_string_from_file_line Date: 09 Jun 2003 21:53:56 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87he6z9gdn.fsf@zagadka.ping.de> References: <3ECFDA48.309D0F5@veritas.com> <87el2dlg9s.fsf@zagadka.ping.de> <3EDA643E.2215A945@veritas.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1055189825 22325 80.91.224.249 (9 Jun 2003 20:17:05 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 9 Jun 2003 20:17:05 +0000 (UTC) Cc: guile development Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jun 09 22:17:03 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19PT4h-0005nx-00 for ; Mon, 09 Jun 2003 22:17:03 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19PT41-00086w-62 for guile-devel@m.gmane.org; Mon, 09 Jun 2003 16:16:21 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19PSsq-0005Xm-0p for guile-devel@gnu.org; Mon, 09 Jun 2003 16:04:48 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19PSmx-0003ZR-Ck for guile-devel@gnu.org; Mon, 09 Jun 2003 15:58:44 -0400 Original-Received: from mail.dokom.net ([195.253.8.218]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19PSjV-0002yR-3T for guile-devel@gnu.org; Mon, 09 Jun 2003 15:55:09 -0400 Original-Received: from dialin.speedway42.dip223.dokom.de ([195.138.42.223] helo=zagadka.ping.de) by mail.dokom.net with smtp (Exim 3.36 #3) id 19PSjY-0005XT-00 for guile-devel@gnu.org; Mon, 09 Jun 2003 21:55:12 +0200 Original-Received: (qmail 25555 invoked by uid 1000); 9 Jun 2003 19:53:56 -0000 Original-To: Bruce Korb In-Reply-To: <3EDA643E.2215A945@veritas.com> Original-Lines: 56 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-cc: Bruce Korb X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2516 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2516 Bruce Korb writes: > Marius Vollmer wrote: > > > void > > scm_c_primitive_load_from_string (const char *str, > > const char *filename, int line) > > { > > SCM port, exp; > > > > port = scm_open_input_string (scm_str2string (str)); > > scm_set_port_file_name_x (port, scm_str2string (filename)); > > scm_set_port_line_x (port, scm_int2num (line)); > > > > while (!SCM_EOF_OBJECT_P (exp = scm_read (port))) > > scm_primitive_eval_x (exp); > > } > > > > I think this quite straightforward, no? > > No. Err, I mean, once you see how it is done. The manual can be improved, I'm sure. > [...] I also try to avoid gratuitous creations of > string SCM's since the file name is generally invariant. > You omitted returning the final value, which is important :-). As you see, there are quite some variants on this theme, and I think the above code is clean enough to allow for easy modification. There is no black magic in it. > It's easier to ignore if the caller doesn't want it. And, no, > I didn't find that the research required to do this was obvious. > In fact, there is no ``scm_set_port_file_name_x'' in 1.6.3, so > you must be talking 1.7 here. Oops, it is "scm_set_port_filename_x". > I'm still working with 1.4. Therefore, I must directly assign to > ``file_name''. I may as well assign the line number, too. One more reason to join the happy Guile 1.6 club... > I'd rather it was ready made so I can just #define my > ``ag_scm_c_eval_string_from_file_line'' into > ``scm_c_primitive_load_from_string''. You might tweak it a bit so a > NULL file pointer bypasses the scm_set_port_file_name_x call. I'd > also use "file_line" in the name, but that is your call. Given these minor variations, I suggest you just use the function from above. That way, you get exactly what you want. -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel