Re: @Delegate and Date

2016-10-25 Thread o...@ocs.cz
Hello there, > On 25. 10. 2016, at 11:40 PM, David Karr wrote: > On Tue, Oct 25, 2016 at 1:34 PM, Dinko Srkoč wrote: >> On 25 October 2016 at 16:02, VG wrote: >>> why this does not work? >>> >>> class Example { >>>@Delegate Date when >>> } >>> >>> def x = new Example(when: new Date()) >>>

Re: .with() variant that returns the original object

2016-11-08 Thread o...@ocs.cz
Paul, > On 9. 11. 2016, at 2:43 AM, Paul King wrote: > Everything you say is true but withThis() has some subtle issues. > It would be a fine name for the current with() method, so it's hard to > distinguish between the two. That's why I have suggested to part with the original one (but for back

improve null-handling

2017-02-19 Thread o...@ocs.cz
Hi there, is there a way to make sure in Groovy (a) that instead of "Cannot cast object 'null' with class 'null' to class 'XXX'" for numeric primitive types XXX (like int) one gets simply a XXX containing 0 (b) that instead of "Cannot resolve which method to invoke for [null] due to overlappin

java.lang.IllegalArgumentException, Groovy 2.4.7, _might_ be caused by Java 8

2017-07-30 Thread o...@ocs.cz
Hi there, I have got the following code (part of a big project): === class AuctionTable extends SecureComponent { public AuctionTable(WOContext context) { super(context) showClosedAuctions=... some expression ... // the fail line 8, see please below ... ... } bool

parser problem?

2020-05-15 Thread o...@ocs.cz
Hi there, lately, I have upgraded to Groovy 3.0.3 from 2.4.17, and have found expressions like this one: 1>2?[3] as Set:null which used to be parsed properly by Groovy 2 do not work anymore. It can be fixed by enclosing the [3] as Set into parentheses, but of course it's a bit at the inconven

More Groovy 3 woes

2020-05-15 Thread o...@ocs.cz
Hi there, having enclosed all the “foo as bar”'s in ternary operators in parentheses, I have bumped into a completely weird problem which I can't wrap my head on -- for many classes I am with Groovy 3 getting completely weird errors of kind “constructor X in class Y cannot be applied to given t

Another ASTT question: own error collector, best way?

2020-05-19 Thread o...@ocs.cz
Hi there, well, another thing I need to tweak in the compiler is to change the way the errors and warnings are reported. I actually have a trick which so far seems to work and which I bumped into years ago. It looks like this (again removed the self-evident parts); as you can see, it is far fr

misplaced else inside a closure causes wrong (or at least pretty weird) error placement with Parrot

2020-05-19 Thread o...@ocs.cz
Hi there, perhaps this is a known or well-understand issue, but worth reporting IMHO (not sure whether worth a ticket; let me please know should I create one for this): === 281 ocs /tmp> /usr/local/groovy-2.4.17/bin/groovyc q.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException

static propertyMissing still catches inherited methods

2020-05-19 Thread o...@ocs.cz
Hi there, I happened to bump into an ancient problem, which, alas, still seems to be sported by even the newest Groovys: a call of an inherited static method is caught by a static propertyMissing handler, which does not seem to be the intended result. Here's the ticket: https://issues.apache.o

With indy, which JARs to classpath? (was:How to test and deploy without groovy-all?)

2020-05-21 Thread o...@ocs.cz
Well, one (most probably and hopefully) last question in this thread. It's probably pretty stupid and (ii)'s probably the self-evident answer, but after the previous debate, I do not quite trust my intuition with using JARs anymore :) With the 4.0 snapshot which I have used so far, the classpat

Should “as Object[]” resolve GStrings?

2020-05-21 Thread o...@ocs.cz
Hi there, I've just bumped into this -- is it the intended behaviour? As always I might be missing something of importance, but it seems pretty inconsistent to me; I would assume all the objects inside should be left as-are, untouched: groovy:000> a=["Hi ${'there'}"] ===> [Hi there] groovy:000>

do I miss something here, or is this a Groovy bug?

2020-05-27 Thread o...@ocs.cz
484 ocs /tmp> /usr/local/groovy-3.0.4/bin/groovy q this is OK this crashes Caught: groovy.lang.MissingPropertyException: No such property: _objects for class: Foo groovy.lang.MissingPropertyException: No such property: _objects for class: Foo at Root$_test_closure1.doCall(q.groovy:13)

Re: ASTT to convert positional to named?

2020-05-31 Thread o...@ocs.cz
MG, > On 31. 5. 2020, at 6:37 PM, MG wrote: > Inhowfar would that differ from the existing map based argument support, like > @NamedVariant etc > (http://docs.groovy-lang.org/2.5.0/html/gapi/groovy/transform/NamedVariant.html) > >

Is there a way for an object to know it _enters_ a try-with-resource block?

2020-06-01 Thread o...@ocs.cz
Is there some trick which would, with a proper replacement of ???, ensure that the following code: === class Foo { void ???() { println "Hi" } void close() { println "Bye" } } ... def foo=new Foo() println "1" try (foo) { println "2" } println "3" try (foo) { println "4" } println "5" === pr

Re: Is there a way for an object to know it _enters_ a try-with-resource block?

2020-06-01 Thread o...@ocs.cz
somethingSmart()==[b,c] } === Does Java or Groovy allow to write such kind of “somethingSmart”? How? Thanks, OC > On 2. 6. 2020, at 2:28 AM, o...@ocs.cz wrote: > > Is there some trick which would, with a proper replacement of ???, ensure > that the following code: > > === >

Re: Add static iterator() methods to classes

2020-06-03 Thread o...@ocs.cz
Felix, I am not sure whether I understand properly the question, but if so... > On 3. 6. 2020, at 10:00 AM, Felix Dorner wrote: > I found that if I add a static iterator() method to a class: > > MyClass.class.metaClass.static[iterator] = { calculateTheIterator() } > > I can use MyClass.each/gr

groovyc stopped to compile Java after Big Sur update

2021-01-29 Thread o...@ocs.cz
Hi there, I've got a project which uses both Groovy and Java sources. After Big Sur update -- without touching the project, it remained unchanged and does build perfectly on my other machine with a Catalina -- it reports “unable to locate the java compiler com.sun.tools.javac.Main, please chang

Re: groovyc stopped to compile Java after Big Sur update

2021-01-29 Thread o...@ocs.cz
ong path without the -V switch: === 1 ocs ~> /usr/libexec/java_home /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home 2 ocs ~> === Thanks a lot, OC > > On 1/29/21, 8:47 AM, "o...@ocs.cz" wrote: > >Hi there, > >I've got a project wh

Re: groovyc stopped to compile Java after Big Sur update

2021-01-29 Thread o...@ocs.cz
P.S. > On 29. 1. 2021, at 6:50 PM, o...@ocs.cz wrote: > Nevertheless, there's no JAVA_HOME at all on my Catalina either, and groovy > compiles Java in there without a glitch. How comes? Hmmm... I wonder. Perhaps the groovy compiler is smart enough to call /usr/libexec/java_home

ASTT not applied when compiling a script?

2021-03-28 Thread o...@ocs.cz
Hi there, my application contains some ASTTs which need to be applied to scripts which it compiles. The code looks essentially like this (a bit simplified for better readability; in practice there are try/catch harnesses, logs, expressions use bindings, and such stuff): === @Lazy(soft=YES)

dynamically install a method/property to be visible through reflexion?

2021-08-26 Thread o...@ocs.cz
Hi there, the subject says it all. I've asked this long time ago (and got a negative answer then), but meantime there's Groovy 3. Is there now a way to do that? Most important it would be with my own class (subclass of a library class), if it helps to find a solution. Thanks, OC

Re: dynamically install a method/property to be visible through reflexion?

2021-08-26 Thread o...@ocs.cz
pis... but no, > they won't be findable/reflectable by Java code. > > -- > Rachel Greenham > rac...@merus.eu <mailto:rac...@merus.eu> > >> On 26 Aug 2021, at 14:35, o...@ocs.cz <mailto:o...@ocs.cz> wrote: >> >> Hi there, >> >> the subject say

override a private method?

2021-10-16 Thread o...@ocs.cz
Hi there, for some testing, I would need to normally override a private method in my subclass. === library looks like this (decompiler says) class Foo { private List _bar(List arg) { ... ... ... } } === what I would need to do in my code, conceptually class MyLogger extends Foo { // I can make

Re: Groovy 4 and Parrot Parser performances

2022-07-23 Thread o...@ocs.cz
Jérémie, you definitely can precompile scripts. There might be a better/simpler/more reliable way, but what I use for years is essentially this (somewhat simplified for better readability): === @Lazy() static emptyBinding=new Binding() @Lazy() static shell={ def cc=new CompilerC

overriding a method for a null argument

2023-10-13 Thread o...@ocs.cz
Hi there, isn't this a bug in the method dispatcher? (Works precisely same way with explicit .plus(...)) I would assume "null: null" to be printed out by the last command: === 2016 ocs /tmp> 'thread' } // just to make sure adding methods works OK Integer.metaClass.plus<<{ org.codehaus.gro

Re: Static typing question

2023-12-31 Thread o...@ocs.cz
Hi there, > On 31. 12. 2023, at 5:20, Agile Developer wrote: > can you give me a case not covered by a typed language? I'm really curious, > because the more I think the more I see modern PL practice/research has > uncovered typed language strengths. These days, typed languages solve more > a

static method using a default instance?

2024-04-19 Thread o...@ocs.cz
Hi there, I've bumped into a pretty trivial problem, but probably I've got a dumb day today — can't find a solution :( How does one write a method which can be called either over an instance, or over a class, in which case it would automatically use a default instance? Like this, in pseudo-cod

Re: Sort on linkedlists with double values (inside main list)

2024-05-20 Thread o...@ocs.cz
Paul, side question, completely irrelevant to the original problem, just occurred to me when I read this... > On 20. 5. 2024, at 17:02, Paul King wrote: > println ([[x:1, y:100], [x:2, y:1], [x: 2, y:500]].sort{ a, b -> a.x == b.x > ? a.y <=> b.y : a.x <=> b.x }) // works Wouldn't sort { a,b

Re: Interesting problem only on Mac!

2024-06-24 Thread o...@ocs.cz
Tommy, I guess you might get more detailed info if you add the JVM option “--illegal-access=debug”. (Groovy works for me on Mac pretty nicely for years :)) All the best, OC > On 24. 6. 2024, at 14:50, Tommy Svensson wrote: > > Hmm > >It is the JDK that produces the message. ==> I b

Re: Confused about scope

2024-09-27 Thread o...@ocs.cz
Blake, > On 27. 9. 2024, at 21:04, Blake McBride wrote: > It is my opinion that having private and package-level scoping is critical. > Controlling scope is critical to managing a large project. In my personal experience, not quite. I have worked as both part and leader of a team on a couple

More or less solved: How to make Geb work?

2024-10-17 Thread o...@ocs.cz
Hi there, well, looks like the claim “all I need is geb-core JAR” is patently false :( When instead of downloading the JAR manually and putting it to the classpath (which approach I happen to strongly prefer) I use @Grab to get dependences as well, it more-or-less starts working. There are som

Re: null-specific argument type?

2025-02-01 Thread o...@ocs.cz
like you suggest. I couldn't find it right now in a Jira or the >> current mailing lists. Maybe it was codehaus days. >> >> The original thinking of NullObject was that it shouldn't normally >> appear in user code. But maybe it's fine in this case. >> >

null-specific argument type?

2025-01-30 Thread o...@ocs.cz
Hi there, is there a way to write a method with argument which would match null specifically when called? This does not work: === 1022 ocs /tmp> /usr/local/groovy-4.0.25/bin/groovy q Caught: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method Test#foo. Cannot resolve w

newInstance vs Object[]

2025-01-24 Thread o...@ocs.cz
Hi there, is there a way to create an Object[] through newInstance? Whatever I have tried (e.g., Object[0].newInstance() and similar ugly contraptions) did fail. Of course, new works all right, but I wonder whether I could use newInstance consistently in all my code. Thanks! OC

safe call evaluates arguments first?

2025-03-27 Thread o...@ocs.cz
Hi there, I've just bumped into this behaviour, as shown e.g., by the code quoted below. A safe method call first evaluates method's arguments, and only then trashes the call. Is this the intended behaviour? It would seem to me much better if the arguments were not evaluated in this case (prec

Re: Groovy -jar

2025-02-23 Thread o...@ocs.cz
Per, we sort of have debated this some time ago, when groovy-all.jar was, sadly, removed. We use a similar approach, nevertheless, we need much more complex classpath. On the other hand, since we deploy WebObjects, we just could take the standard NeXT/Apple WO launch script and very slightly c

Re: Groovy -jar

2025-02-23 Thread o...@ocs.cz
C > On 24. 2. 2025, at 1:51, steve.etchel...@gmail.com wrote: > > Per, > > Out of curiosity why wouldn’t you want to include groovy jars in every jar > bundle. Is it the maintenance of groovy security patches? It isn’t the > storage is it? > > From: o...@ocs.