variable substitution

0 votes
asked Dec 6, 2018 in Bug by Remco Boerma

I'm started to get what's bugging me:

!define i j
!define h i
!define g h
title g h i 

Try for yourself I'm baffled by this. Tried it with a different order of defines, and that didn't help either. I'm losing "objects" this way.
commented Dec 7, 2018 by mgrol (3,150 points)
Btw. You opened two issues to the same subject
http://forum.plantuml.net/8666/define-within-a-macro-destroys-reference
I also enhanced your provided diagram to explain what happens.

2 Answers

0 votes
answered Dec 7, 2018 by plantuml (294,960 points)

Thanks for the feedback, it's a very good snipset.

To be clear, could you tell us what is your expected result of this one ?

I guess it's : h i j

Right ?

commented Dec 10, 2018 by Remco Boerma
Exactly, that was my assumption as well and would be most useful!
0 votes
answered Dec 7, 2018 by albert (3,520 points)

I think the answer j j j is correct.

Compare the C program:

#define i j
#define h i
#define g h
#include <stdio.h>

void main(int argc, char ** argv)
{
  //title g h i
  int j = 3;
  printf("%d %d %d %d\n",g,h,i,j);
}

running this results in:

3 3 3 3

commented Dec 10, 2018 by Remco Boerma
I'm baffled again, that might be useful in C, but it's not that useful to non-c programmers.

I would like to get the result expected by @plantuml
commented Dec 14, 2018 by albert (3,520 points)
I think it is all about the fact of "recursive" / "non-recursive" substitutions. Especially when creating complex defines it is good to split in simple parts and do a "recursive" substitution.

(Sorry for the late response, it landed in my spam box :-( ).
...