It is currently Sun Dec 16, 2018 10:18 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Allow: Macro Test(ID, Text$, Word.s, , Line.i)
PostPosted: Thu Mar 29, 2018 6:54 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 276
Location: Germany
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:
Macro Test(ID, Text$, Word.s, Line.i)
  ; ...
EndMacro

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Last edited by Sicro on Sun Apr 08, 2018 12:32 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Macro Test(ID, Text$)
PostPosted: Thu Mar 29, 2018 7:56 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2760
Location: Boston, MA
The suffix '$' = String datatype.
Macros perform search and replace before compile. Datatypes have no meaning before compile.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Macro Test(ID, Text$)
PostPosted: Thu Mar 29, 2018 8:48 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1476
Location: Germany
Simple way is with prefix...
Code:
Macro foo(iID, sText, lValue, wValue, pPointer)
  ; 
EndMacro

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Macro Test(ID, Text$)
PostPosted: Fri Mar 30, 2018 6:21 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 276
Location: Germany
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:
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:
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.

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: Macro Test(ID, Text$)
PostPosted: Sat Mar 31, 2018 7:25 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jun 28, 2003 12:01 am
Posts: 489
Sicro wrote:
... although the suffix "$" would be more understandable.

;-)
I never use the $ sign for text variables!
;-)

_________________
Windows 10 / Windows 7
PB Last Final / Last Beta Testing


Top
 Profile  
Reply with quote  
 Post subject: Re: Macro Test(ID, Text$)
PostPosted: Sun Apr 01, 2018 6:28 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3225
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. :D

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Macro Test(ID, Text$)
PostPosted: Sun Apr 01, 2018 6:59 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2760
Location: Boston, MA
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.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow: Macro Test(ID, Text$, Word.s, , Line.i)
PostPosted: Sun Apr 08, 2018 12:36 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 276
Location: Germany
I have edited my first post to take into account the other variable definitions.

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow: Macro Test(ID, Text$, Word.s, , Line.i)
PostPosted: Sun Apr 08, 2018 6:16 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2096
Location: Singapore
Sicro wrote:
Code:
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:
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. :wink:

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow: Macro Test(ID, Text$, Word.s, , Line.i)
PostPosted: Sat Apr 14, 2018 12:20 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 276
Location: Germany
TI-994A wrote:
Code:
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.

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye