macro expansion in two steps with ## does not work

0 votes
asked Sep 21, 2016 in To be sorted by andreas.kagedal (320 points)
I think there is a problem when expanding macros into other macros which are using ##
 
Here is an example which illustrates the problem.
 
--
!definelong SEND_TO_b(from,message)
  from -> b : MYPROT:\n##message
!enddefinelong
 
!define SEND_FROM_a_TO_b(message) SEND_TO_b(a,message)
 
SEND_TO_b(a,Hello)    'Works fine
SEND_FROM_a_TO_b(Hi)  'Does not work
--
The expected behavior is that thre should be two arrows from a to b, where the first one is labled "
 
MYPROT:
Hello
 
and the second one is labled
 
MYPROT:
Hi
 
However the second arrow is instead labled
 
MYPROT:
message
 
To see that this is related to the use of ## in the macro, replace the ## with a space (which will indent the second row slightly) The second arrow will then be labled
 
MYPROT:
 Hi
 
I guess this is a bug-report, but I could not find where to report this.
MYPROT:
Hi

1 Answer

+1 vote
answered Sep 21, 2016 by plantuml (298,440 points)

Thanks for the report, this is the right place to do bug-report.

We'll investigate this.

Note that changing macro definition fixes the issue. Don't know if this is a workaround for you.

@startuml
!define SEND_FROM_a_TO_b(message) SEND_TO_b(a,message)
!definelong SEND_TO_b(from,message)
  from -> b : MYPROT:\n##message
!enddefinelong
 
 
SEND_TO_b(a,Hello)    'Works fine
SEND_FROM_a_TO_b(Hi)  'Does not work
@enduml

commented Sep 21, 2016 by andreas.kagedal (320 points)
Thanks! Just changing the order in which the macros are defined solved it. It is certainly a workaround that works for me. Thanks!
...