Language Syntax Honouring the name BASIC

Everything else that doesn't fall into one of the other PB categories.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Language Syntax Honouring the name BASIC

Post by Keya »

Fred wrote:@Keya: you can put your macro in a resident file (see http://www.purebasic.com/documentation/ ... piler.html for the syntax to create one), it will gets loaded everytime PB loads.
Excellent, thanks!!! Permanent macros and boosted productivity here we come!:)

Code: Select all

Cross-platform command switches
    -r, --resident, /RESIDENT "filename": creates a resident file specified by the filename.
    -ir, --ignoreresident, /IGNORERESIDENT "filename": doesn't load the specified resident file when the compiler starts.
           It's mostly useful when updating a resident which already exists, so it won't load it. 
and then i can just link my macro file at pastebin in my sig for others using my code :D

hmmm several downsides of using macro though...
one is structure contents are no longer recognised (by the IDE) :(

Code: Select all

Macro Struct
    Structure
EndMacro
    
Struct MyTest
var1.i
var2.i
EndStructure

Define Test.MyTest
Test\var...    ; <-- Typing "Test\" here normally would suggest var1 and var2 available, but due to macro it doesnt?
so im not sure if i can use that (for structures anyway) because i find that helper invaluable when it comes to complex structures, also saves having to waste time scrolling through source looking for the structure definition.

Likewise, if you do one for say MsgBox = MessageRequester, when you type "MsgBox(" you no longer get the parameter suggestions in the bottom statusbar ("Title.s, Message.s, [flags.i]" etc)

Would be great if the IDE was able to expand the macro and detect, problem would be solved i guess.

The lack of bolding/highlighting is also a bit weird though, looks like ive inserted plaintext amongst the code [edit] can use Custom Keywords for this, nice
Last edited by Keya on Tue Mar 01, 2016 11:36 am, edited 1 time in total.
User avatar
Derren
Enthusiast
Enthusiast
Posts: 318
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Language Syntax Honouring the name BASIC

Post by Derren »

You can add your keywords to the list of "custom" keywords in the preference menu.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Language Syntax Honouring the name BASIC

Post by Keya »

Ahh nice!
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Frarth »

For anyone who's interested, here is a start off:

Code: Select all

; keyword replacement macros
; --------------------------
macro explicit
  enableexplicit
endmacro

macro subreturn
  procedurereturn
endmacro

; for readibility
macro exitsub
  procedurereturn
endmacro

macro local
  protected
endmacro

macro sub
  procedure
endmacro

macro endsub
  endprocedure
endmacro

macro include
  IncludeFile
endmacro

macro xinclude
  XIncludeFile
endmacro

macro type
  structure
endmacro

macro endtype
  endstructure
endmacro

macro ClearType
  ClearStructure
endmacro

macro CopyType
  CopyStructure
endmacro

macro union
  structureunion
endmacro

macro endunion
  endstructureunion
endmacro

macro enum
  enumeration
endmacro

macro endenum
  endenumeration
endmacro
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Language Syntax Honouring the name BASIC

Post by Danilo »

Do you make a difference between Sub and Function?

I guess we will see very different styles in the future, after nearly 20 years of PB:

Code: Select all

Structure/EndStructure
Struct/EndStruct
Type/EndType
S/ES
T/ET

Procedure/EndProcedure
Sub/EndSub
Function/EndFunction
Proc/EndProc
Func/EndFunc
Fn/EndFn
Last edited by Danilo on Tue Mar 01, 2016 12:24 pm, edited 1 time in total.
sys64802
Enthusiast
Enthusiast
Posts: 105
Joined: Sat Sep 12, 2015 6:55 pm

Re: Language Syntax Honouring the name BASIC

Post by sys64802 »

Danilo wrote: I guess we will see very different styles in the future, after nearly 20 years of PB:

Code: Select all

Structure/EndStructure
Struct/EndStruct
Type/EndType
S/ES
T/ET

Sub/EndSub
Function/EndFunction
Func/EndFunc
Fn/EndFn
Just what the doctor ordered for the code posted in the forum. :wink:
I think that's ok if you don't share anything, else it's just a PITA imo.
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Language Syntax Honouring the name BASIC

Post by DK_PETER »

Danilo wrote:Do you make a difference between Sub and Function?

I guess we will see very different styles in the future, after nearly 20 years of PB:

Code: Select all

Structure/EndStructure
Struct/EndStruct
Type/EndType
S/ES
T/ET

Procedure/EndProcedure
Sub/EndSub
Function/EndFunction
Proc/EndProc
Func/EndFunc
Fn/EndFn
I really don't think so.
The option to use macros has been used frequently in f.ex PurePunch competitions to produce
smaller and very frequently totally unreadable code. :)
My bet is that function renaming is probably only interesting for the very few.
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Frarth »

Danilo wrote:Do you make a difference between Sub and Function?

I guess we will see very different styles in the future, after nearly 20 years of PB:

Code: Select all

Structure/EndStructure
Struct/EndStruct
Type/EndType
S/ES
T/ET

Procedure/EndProcedure
Sub/EndSub
Function/EndFunction
Proc/EndProc
Func/EndFunc
Fn/EndFn
SUB and FUNCTION are two different keywords for the same thing. From a programming technical point of view it does not really matter whether or not a routine returns a value. Even a procedure in purebasic without a type indicator returns a value (0) if used as a function and visa versa. So adding a type indicator like SUB.d is sufficient as it already tells me the routine is designed to return a result. So using FUNCTION doesn't improve readability in my opinion and the keyword is already too long.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Zebuddi123 »

There is all so the Code Template in the tools panel, set your code up double click all inserted. It would be great if when defining the template the cursor would be repositioned to the same line as when defining the template. It also has folders/treeview .

Zebuddi. :)
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
TI-994A
Addict
Addict
Posts: 2771
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Language Syntax Honouring the name BASIC

Post by TI-994A »

Frarth wrote:

Code: Select all

; keyword replacement macros
; --------------------------
macro explicit
  enableexplicit
endmacro

macro subreturn
  procedurereturn
endmacro

; for readibility
macro exitsub
  procedurereturn
endmacro

macro local
  protected
endmacro

macro sub
  procedure
endmacro

macro endsub
  endprocedure
endmacro

macro include
  IncludeFile
endmacro

macro xinclude
  XIncludeFile
endmacro

macro type
  structure
endmacro

macro endtype
  endstructure
endmacro

macro ClearType
  ClearStructure
endmacro

macro CopyType
  CopyStructure
endmacro

macro union
  structureunion
endmacro

macro endunion
  endstructureunion
endmacro

macro enum
  enumeration
endmacro

macro endenum
  endenumeration
endmacro
These in no way "honour" the original BASIC; most of them weren't even in the original language. :lol:

Moreover, such redundant substitutions would only confuse and impede debugging.

Stop reinventing the wheel and learn the language. :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! Please visit my YouTube Channel :D
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Frarth »

TI-994A wrote: These in no way "honour" the original BASIC; most of them weren't even in the original language. :lol:

Moreover, such redundant substitutions would only confuse and impede debugging.

Stop reinventing the wheel and learn the language. :wink:
After 7 years PB I should learn the code LOL. Where am I reinventing the wheel? As I said in the original post, first of all it is about preferring shorter keywords. Nothing more nothing less. In addition IMO sub/endsub etc would also fit the name PureBASIC better. But again, it's a matter of opinion. Bu thank you for your advice. :lol:
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Language Syntax Honouring the name BASIC

Post by srod »

I am so used to the verbose syntax now (if it is indeed verbose! :) ) that I would personally seek out anyone responsible for changing the syntax and force feed them a pair of Fangbeast's festering underpants. And that would just be the appetizer before the main course! :)

Of course, I would be left having to explain how a pair of his festering jockies came to be in my possession, but I am sure I can come up with a plausible explanation before tea time! :shock:
I may look like a mule, but I'm not a complete ass.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Language Syntax Honouring the name BASIC

Post by HanPBF »

As was written macros work with user defined keywords -> so, autocompletion available.

Or use macro expansion by command line -> still no formatting kept there?

Code: Select all

macro sub
	procedure
		; this is generated by macro 
endmacro	

sub test()
EndProcedure

Procedure test2()
EndProcedure
gets after PREPROCESS

Code: Select all

macro sub
	procedure
		
endmacro	
procedure test()
EndProcedure
Procedure test2()
EndProcedure
comments deleted in macro; all the formatting gone away...

How can I prevent this???
--commented is not an option (does simply comment all original source)
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Language Syntax Honouring the name BASIC

Post by Tenaja »

Just remember, the design intent for BASIC was not to make it easy to type, but to make the code fit into ram-limited systems. As such, short or long commands have nothing to do with "honoring BASIC".

Also, +1 to TI-994a:
These in no way "honour" the original BASIC; most of them weren't even in the original language. :lol:
When I was a newbie to PB, I used numerous macros, myself, to make it more comfortable/familiar for me. Over a few months, however, I grew out of that and started using pure PureBasic. Within a few years, I even forgot those early months, until I went back and looked at my early code...and as I did, I wondered what the heck I was thinking. I know some of the old dogs on the forum are older than the one typing this, but still, embrace it purely, and it will be easier in the long run.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Language Syntax Honouring the name BASIC

Post by HanPBF »

Hello Tenaja,
When I was a newbie to PB, I used numerous macros, myself, to make it more comfortable/familiar for me. Over a few months, however, I grew out of that
What do You mean saying "grew out of that"? Maybe doing more the direct, very verbose PB way? Or using preprocessor?

I also used macros intensively; then I saw that debugging and autocompletion is not supported and PREPROCESS does neither help.
Autocompletion with macros -> o.k. very difficult to implement
Debugging -> steps over the macros; IDE is source code based not AST based, so o.k.

So, the question is why not to use macros (for shortcuts); I think only due to lack in support, either by implementation or by design, nothing else.

At the end, result ist the same: "prevent using macros", I agree with that.
Post Reply