[ATL]println() in declarative expressions? [message #52417] |
Fri, 13 July 2007 10:51  |
Eclipse User |
|
|
|
Originally posted by: matt.mcgill.gmail.com
I'll state right up front that what I'm trying to do is really ugly, and
probably not a good idea. That being said, I still wish I could do it =)
I was hoping to get some debug output during the evaluation of a
recursive helper. The helper looks like this:
helper context UML!Namespace def:
firstStateMachine : UML!StateMachine =
let debug3 : String =
'firstStateMachine ('+self.name+')'.println() in
if self.oclIsTypeOf(UML!StateMachine) then
let debug1 : String =
'firstStateMachine: found statemachine'.println() in
self
else
let debug2 : String = 'firstStateMachine: iterating'.println() in
self.ownedElement->collect(c |
if c.oclIsKindOf(UML!Namespace) then
Sequence {c.firstStateMachine}
else
Sequence {}
endif
)->flatten()->first()
endif;
I was hoping that println() evaluated to the string it was printing,
which would cause the above to work. However, when I tried to execute
the transformation containing this helper, I received the first line of
output ('firstStateMachine (foo)') and immediately thereafter an
EmptyStackException, so I presume that println() does *not* evaluate to
anything, and is only meant for imperative statements. Nuts.
So here's my question: is there any technical hurdle that would prevent
println() from evaluating to a String (and thereby enabling its use in
declarative expressions)? Because it would make debugging a lot easier =)
Why am I not using the debugger, you ask? Because I'm executing my
transformation programmatically, in a JUnit test, that's why! TDD and
all that...
Thanks, and sorry for suggesting such an atrocity,
-Matt McGill
|
|
|
|
|
|
Re: [ATL]println() in declarative expressions? [message #52503 is a reply to message #52477] |
Fri, 13 July 2007 12:06  |
Eclipse User |
|
|
|
Originally posted by: matt.mcgill.gmail.com
Guilaume Hillairet wrote:
> Hi,
>
> The function you're searching for is .debug(String)
>
Thanks, that's exactly what I meant =) But I didn't expect to find it on
OclAny, so I only looked at the string datatype.
-Matt
|
|
|
Powered by
FUDForum. Page generated in 0.08328 seconds