[plt-scheme] evaluating contents of a string

From: David Richards (vottamusic at verizon.net)
Date: Wed Jul 26 22:02:55 EDT 2006

On Jul 25, 2006, at 10:53 PM, Chris Warrington wrote:

> David Richards @ 2006-7-25 10:46:15 PM
> "[plt-scheme] evaluating contents of a string" 
> <mid:ac01fb5e725b12548648a10157eeb98d at verizon.net>
>> Given:
>> "(lambda () (current-seconds))"
>> What is the 'best practice', or most elegant way to obtain a scheme
>> procedure from the contents of a string?
> I'd use:
> (eval (read (open-input-string "(lambda () (current-seconds))")))

Thanks for that, and to everyone else for all the advice.

Questions... in the example above, what happens to the input port?  
Don't we need to close the input port explicitly?  I was under the 
impression that unclosed ports become 'leaks' if we don't explicitly 
close them before exiting an execution context.  Is it safe to leave a 
port unclosed in a context that is eligible for garbage collection?  
Does the garbage collector close ports that are left open?  If so, why 
is there all the harsh exhortation in the documentation to close open 
ports when finished with them?

- dr

> -- 
> Chris Warrington <chrisw at rice.edu>
> "The Ten Commandments contain 297 words. The Bill of Rights is stated
> in 463 words. Lincoln's Gettysburg Address contains 266 words. A
> recent federal directive to regulate the price of cabbage contains
> 26,911 words."
> -Atlanta Journal_________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.