From: Chad Perrin Date: 2008-10-15T03:38:58+09:00 Subject: Re: Sample for Metaprogramming --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Oct 12, 2008 at 02:35:34AM +0900, Sebastian Hungerecker wrote: > relzne@bluewin.ch wrote: > > Can anyone give me a good small sample for Metapgramming with Ruby? >=20 > There you go: [snip] >=20 > Ok, this took way more time to write than I expected and also turned out = quite=20 > a bit bigger and isn't really tested very thoroughly. But the idea is a s= uch: >=20 > Using Files.in(dirname) you can get a class representing that directory. > This class will have a method for every file in that directory. > Calling such a method will give you an instance of the class, representin= g the=20 > specific file. > Calling new(filename) on the class will create a file in that directory. > The class is extended with Enumerable and you can use it to iterate over = its=20 > instances representing the files that exist the directory. >=20 > Of course this is quite a complicated way to work with files, but you wan= ted=20 > meta-programming, so there you go. > (I did intend this to be simpler than it turned out to be, though) Is there anyone here that knows Lisp well enough to provide a Lisp example that does the same thing, just for purposes of comparing how the two languages handle these techniques? --=20 Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ] H. L. Mencken: "In this world of sin and sorrow, there is always something to be thankful for; as for me, I rejoice that I am not a Republican." --CE+1k2dSO48ffgeK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkj05U8ACgkQ9mn/Pj01uKWzfgCfTtI88i1nSX9Ie7EGFUIPWvoS 6EQAoML9eETsxbyu0+pDSuo9B2R2xwXS =/nCv -----END PGP SIGNATURE----- --CE+1k2dSO48ffgeK--