Page 1 of 1
Allow: Macro Test(ID, Text$, Word.s, , Line.i)
Posted: Thu Mar 29, 2018 6:54 pm
by Sicro
To determine whether a macro parameter requires a number or a string, it would be good if the parameter name can have a dollar sign ($) at the end or a dot inside.
Code: Select all
Macro Test(ID, Text$, Word.s, Line.i)
; ...
EndMacro
Re: Macro Test(ID, Text$)
Posted: Thu Mar 29, 2018 7:56 pm
by skywalk
The suffix '$' = String datatype.
Macros perform search and replace before compile. Datatypes have no meaning before compile.
Re: Macro Test(ID, Text$)
Posted: Thu Mar 29, 2018 8:48 pm
by mk-soft
Simple way is with prefix...
Code: Select all
Macro foo(iID, sText, lValue, wValue, pPointer)
;
EndMacro
Re: Macro Test(ID, Text$)
Posted: Fri Mar 30, 2018 6:21 pm
by Sicro
skywalk wrote:The suffix '$' = String datatype.
Yes, that's why I chose this sign. If someone sees the suffix "$", it is immediately clear that a string is requested.
skywalk wrote:Macros perform search and replace before compile. Datatypes have no meaning before compile.
Yes, I know. My point is that later in the code it should be recognizable whether the macro parameter requires a string or a number.
Code: Select all
Macro Test(Value)
Debug Val(Value)
EndMacro
For example, if I define the above macro in a huge code and I want to call the macro later, I somehow need to know how to enter the values in the macro parameters:
Code: Select all
Test("123")
; or
Test(123)
; I don't know... I must go to the macro definition to take a look...
With procedures, I always see which data type the parameter requires in the status bar of the PB IDE.
mk-soft wrote:Macro foo(... sText ...)
Yes, this is a possibility that is immediately understandable for many programmers, although the suffix "$" would be more understandable.
Re: Macro Test(ID, Text$)
Posted: Sat Mar 31, 2018 7:25 am
by helpy
Sicro wrote:... although the suffix "$" would be more understandable.

I never use the $ sign for text variables!

Re: Macro Test(ID, Text$)
Posted: Sun Apr 01, 2018 6:28 pm
by Mistrel
helpy wrote:Sicro wrote:... although the suffix "$" would be more understandable.

I never use the $ sign for text variables!

I ALWAYS use .s for clarity and to match all other types.

Re: Macro Test(ID, Text$)
Posted: Sun Apr 01, 2018 6:59 pm
by skywalk
I always use myStrVar$ to easily spot a string.
Else you have to use some other prefix to know it is a string.
Like smyStrVar or myStrVar_s.
The trailing $ is just easy.
But I define them with Define.s myStrVar$ for my code parsing tools.
Re: Allow: Macro Test(ID, Text$, Word.s, , Line.i)
Posted: Sun Apr 08, 2018 12:36 am
by Sicro
I have edited my first post to take into account the other variable definitions.
Re: Allow: Macro Test(ID, Text$, Word.s, , Line.i)
Posted: Sun Apr 08, 2018 6:16 am
by TI-994A
Sicro wrote:Code: Select all
Macro Test(ID, Text$, Word.s, Line.i)
; ...
EndMacro
Technically, even if such were to be implemented, it would purely be as syntactic sugar, with no type reflection. And the full notation would have to be expressed within the macro as well;
like so:Code: Select all
Macro Test(ID, Text$, Word.s, Line.i)
Debug Word.s
Debug (Line.i + Line.i)
EndMacro
Because macros merely perform syntactic refactoring without any functional evaluation.

Re: Allow: Macro Test(ID, Text$, Word.s, , Line.i)
Posted: Sat Apr 14, 2018 12:20 am
by Sicro
TI-994A wrote:Code: Select all
Macro Test(ID, Text$, Word.s, Line.i)
Debug Word.s
Debug (Line.i + Line.i)
EndMacro
That's exactly how I imagine it. The names of the macro parameters should also be allowed to contain "$" and dot.