Re: BeanShell Dialects: proposal for future syntax extension mechanism... (Patrick Niemeyer)

Victor Volle <[email protected]> Wed, 2 Feb 2005 17:59:21 +0100
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
Imagine, I want to do create something like Ruby's "each":
A method that takes an Iterator or a collection and a "code block":

   each( file, { line |  
                   // do something
               } 
        );

the single method "each" would work, but could I do something like:

   file.each( line | 
                // do something
            );

The syntactic sugar "{"  and "|" is not important, but being able to
implement functions that are not top level functions but methods of an
object?

Would I have to do something like:

eachLineInFile( self, { ... } );
file.each = eachLineInFile();


Victor



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl