Page 3 of 3
Re: Language Syntax Honouring the name BASIC
Posted: Wed Mar 02, 2016 12:10 am
by Tenaja
HanPBF wrote:Hello Tenaja,
What do You mean saying "grew out of that"? Maybe doing more the direct, very verbose PB way? Or using preprocessor?
I mean I quit trying to conform PB into some other language, and I now use it the way it was designed. Sure, I use macros a lot, but not to rename native commands like Procedure (function) or Protected (local). As others have said, autocomplete is there for a reason.
As much as we'd like to say PureBasic is for beginners, most of us come from some other language, usually another Basic. Almost all of us try to use macros to make it more like where we came from. Most of us grow out of that. That's just an observation from using it for about five years.
Re: Language Syntax Honouring the name BASIC
Posted: Wed Mar 02, 2016 12:24 am
by HanPBF
I like macros with procedures using arrays.
Code: Select all
procedure test(Array Arr1.Struct1(1), Array Arr.Struct2(1))
; loop over the arrays and do something
endProcedure
If 'Struct1' and 'Struct2' would be based on structure 'Struct' and so would 'StructA' and 'StructB', 'StructOne' and 'StructTwo' and I would want to use the same algorithm on the base struct, I can not write a procedure like...
Code: Select all
procedure test(Array Arr1.Struct(1), Array Arr.Struct(1), DoSomething.PrototypeDoSomething)
; loop over the arrays and call DoSomething
endProcedure
...because types of arrays cannot be base type of contained struct elements as parameter.
It seems pretty straight, I guess the size of the arrays must be known at compile time.
If the algorithm for varying types of arrays is nearly the same, I consider this a good method to macro-ize any loop over the very both arrays.
"to conform PB into some other language" -> yes, I agree, that's very often the problem.
I also use doubled tab typing "ProcedureReturn" which I find not so bad.
Regards
Re: Language Syntax Honouring the name BASIC
Posted: Thu Mar 03, 2016 1:32 pm
by Frarth
Tenaja wrote: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.

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.
The title may be somewhat misleading. I put more emphasis on readability and being able to do fast typing. Also, I have been using PureBasic for many years using its native keywords. After being out of it for a while and having used Pascal for specific programming tasks I found myself returning to a somewhat verbose language. So don't think I'm a newbie just starting out with PureBasic. I like doing short coding while still readable and understandable. In the end it's everyone's personal choice.
Re: Language Syntax Honouring the name BASIC
Posted: Thu Mar 03, 2016 1:39 pm
by Frarth
Also, I don't think Purebasic is for beginners. You have to be pretty careful when using pointers. Allowing references to procedures is powerful and advanced programming, usually not found in other basic languages. I feel comfortable using Purebasic. I just like SUB / ENDSUB more than PROCEDURE / ENDPROCEDURE not to mention PROCEDURERETURN. Even with autocomplete on it is a whole lot of typing when programming full time.
Re: Language Syntax Honouring the name BASIC
Posted: Thu Mar 03, 2016 2:14 pm
by HanPBF
PASCAL:
Code: Select all
if (a=b) or (c=d) then begin
...
end else begin
end
One-liners for if are forbidden in any language... (IIf allowed)
PureBasic:
C-like:
PureBasic does it as short as possible keeping it BASIC...
Source is >=95% of the time read not written; I can not see anything annoying in PROCEDURERETURN when
reading it.
So, still a matter of taste...
Re: Language Syntax Honouring the name BASIC
Posted: Thu Mar 03, 2016 2:17 pm
by Frarth
That is why I prefer Purebasic over Pascal and other languages, but sometimes you don't have a choice when doing shared projects.

Re: Language Syntax Honouring the name BASIC
Posted: Sat Mar 05, 2016 12:23 pm
by TI-994A
Frarth wrote:...I don't think Purebasic is for beginners...
Totally untrue. PureBasic offers such a range of diverse cross-platform functionalities that could aid and complement the novice programmer, while still catering to the needs of the professional.
Powerful versatility. 
Re: Language Syntax Honouring the name BASIC
Posted: Sat Mar 05, 2016 1:24 pm
by Frarth
TI-994A wrote:Frarth wrote:...I don't think Purebasic is for beginners...
Totally untrue. PureBasic offers such a range of diverse cross-platform functionalities that could aid and complement the novice programmer, while still catering to the needs of the professional.
Powerful versatility. 
I'm not saying beginners cannot start using Purebasic, but it requires some deeper thinking. It starts with procedure parameters and the lack of BYVAL / BYREF keywords. When passing structures you need to use @ or *, but an array of a structure does not require this because arrays are automatically by reference. When passing a single array element of a nested structure you do need the reference again. You may have grown accustomed to this, but when starting it can be pretty confusing. On top of that, sometimes @* is required, for instance when passing a structure member by reference. This is not easy for a novice programmer.
Re: Language Syntax Honouring the name BASIC
Posted: Sat Mar 05, 2016 3:03 pm
by TI-994A
Frarth wrote:I'm not saying beginners cannot start using Purebasic, but it requires some deeper thinking...
Just to clarify,
ByVal and
ByRef keywords are parameter
functions. With the exception of the
Array keyword, PureBasic passes all parameters by value;
even pointers.
As with anything, beginners simply need to read the manual; no amount of
deeper thinking is going to circumvent that.
Re: Language Syntax Honouring the name BASIC
Posted: Sat Mar 05, 2016 3:59 pm
by bbanelli
TI-994A wrote:As with anything, beginners simply need to read the manual; no amount of deeper thinking is going to circumvent that.
"Painful" truth. If you accompany it with sentence "Computers always do what you
tell them, seldom what you really
want", and you've described the whole IT branch.

Re: Language Syntax Honouring the name BASIC
Posted: Sat Mar 05, 2016 4:32 pm
by Lord
bbanelli wrote:... "Computers always do what you tell them, seldom what you really want" ...
But that they do damn fast.
