tag:blogger.com,1999:blog-5427069094580312550.post8427248028729706611..comments2023-12-23T21:48:09.231-08:00Comments on Code To Joy: Zen and Groovy's ExpandoMichael Easterhttp://www.blogger.com/profile/14799771593145201161noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-5427069094580312550.post-41071054527727819952015-06-11T08:30:25.179-07:002015-06-11T08:30:25.179-07:00Ok, years late to say... but Expando == Expendable...Ok, years late to say... but Expando == Expendable beanAnonymoushttps://www.blogger.com/profile/17372344697226347183noreply@blogger.comtag:blogger.com,1999:blog-5427069094580312550.post-2141991706472304462011-10-15T11:18:14.318-07:002011-10-15T11:18:14.318-07:00For my part one and all must browse on this.For my part one and all must browse on this.www.sillones.nom.eshttp://www.sillones.nom.esnoreply@blogger.comtag:blogger.com,1999:blog-5427069094580312550.post-66116944446543070882007-12-05T06:26:00.000-08:002007-12-05T06:26:00.000-08:00Thanks for the comments, gents...@Alex. I've thoug...Thanks for the comments, gents...<BR/><BR/>@Alex. I've thought about a 'Rosetta Stone' diagram that maps out certain concepts across languages. I didn't know about Beanshell but certainly Javascript (and probably Python, Ruby) have similar behaviour. That's cool re: DSLs.<BR/><BR/>@Jeff. Thanks... Groovy never ceases to amaze me in the sense that there is always one more thing one can do to make it tighter.Michael Easterhttps://www.blogger.com/profile/14799771593145201161noreply@blogger.comtag:blogger.com,1999:blog-5427069094580312550.post-73007447145000560402007-12-04T12:23:00.000-08:002007-12-04T12:23:00.000-08:00Expando is full of schizzle, isn't it? ;)This doe...Expando is full of schizzle, isn't it? ;)<BR/><BR/>This doesn't really have much to do with Expando but your code is calling a closure using the .call() method. If you are invoking a closure from groovy, you can simplify that by treating the closure as a method.<BR/><BR/>// invoke the call method...<BR/>duckTester.call(it)<BR/><BR/>// invoke the closure...<BR/>duckTester(it)Jeff Brownhttps://www.blogger.com/profile/13650645104670573315noreply@blogger.comtag:blogger.com,1999:blog-5427069094580312550.post-43697116964411697332007-12-04T08:30:00.000-08:002007-12-04T08:30:00.000-08:00You can do a similar thing in Beanshell, with if I...You can do a similar thing in Beanshell, with if I remember correctly, a This object, which serves as your context. <BR/><BR/>I found that this was incredibly useful for writing DSLs in BeanShell as you could write scripts that work on a well-known (to the script) set of attributes that are dynamically added to your current context. Presumably, you could leverage Expando in the same way.<BR/><BR/>For example, we created a set of beanshell functions that were basically a DSL for testing JDBC, so we had a function createConnection(...) that took some url/user/pw info, created a connection and stuffed it into a Connection object in context (no Connection is returned). Then other functions that executed a query (using Connection, and stuffing results into a ResultSet in context), walked forward and backward, etc. <BR/><BR/>This made testing JDBC scenarios for our custom JDBC driver really easy to write and understand.Alex Millerhttps://www.blogger.com/profile/01929662536395624733noreply@blogger.com