flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Concatenation # operator for identifiers and literals

Author
Thread Post new topic Reply to topic
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 27 Aug 2022, 10:37
As we all know, the # operator is able to concatenate some identifier-like pieces into a single one:
Code:
match ,
{
  abc # def equ display 'OK'
  abcdef
}    

If also works with string literals:
Code:
match ,
{
  display 'abc' # 'def'
}    

Still it doesn’t work for identifier and literal:
Code:
match ,
{
  abc # 'def' equ display 'OK'
  abc'def'
}    

while
Code:
match ,
{
  abc'def' equ display 'OK'
  abc'def'
}    

works as expected.

I understand the possible ambiguity of whether the result of such concatenation should be a string or an identifier but I also feel being able to concatenate a string literal to an identifier (having a new identifier as a result) would open a lot of possibilities for writing macros that require bookkeeping based on (macro-)user-provided string literals. (I remember it has recently been the case for multisection macros.)

Any reasons why defining the # operator behaviour for non-equal “types” might be impossible / a bad idea?
Post 27 Aug 2022, 10:37
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.