variable substitution

0 votes
asked Dec 6 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 by mgrol (2,560 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 by plantuml (188,240 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 4 days ago by Remco Boerma
Exactly, that was my assumption as well and would be most useful!
0 votes
answered Dec 7 by albert (2,650 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 4 days ago 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 4 hours ago by albert (2,650 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 :-( ).
...