Syntax suggestion in PureBasic

Everything else that doesn't fall into one of the other PB categories.
AZJIO
Addict
Addict
Posts: 2217
Joined: Sun May 14, 2017 1:48 am

Syntax suggestion in PureBasic

Post by AZJIO »

The topic has been raised more than once and even now complex constructions are proposed, which are rather derived functions from the programming language. I have said more than once that I studied AutoIt3 and in my opinion there are ideas there that I would call classic.

1. SetError(), SetExtended(). AutoIt3 has two "variables" @error and @extended. These are just two memory cells, which in the program will be invisible in terms of memory consumption, but provide powerful functionality. This is similar to the GetLastError() function. The use of this data is documented in the function calls, in some it has no value, in others it is reset to zero, and upon completion it contains function execution statistics, for example 1="Failed to open file" (does not exist), 2="could not write to file ". You can set these values ​​yourself using SetError() on your own functions, set the value to 0 at the beginning, and then you can set other values ​​as you go. Before taking the results of the function, you need to check the value of @error. In this case, @extended can contain additional values, for example, when executing ReplaceString(), you can get the number of replacements performed.

2. Continue [Level]
3. ContinueCase
4. Default. PeekS(*mem, Default, #PB_UTF8). You don't need to know the default value (-1) to skip the parameter.
5. #cs, #ce (#comments-start, #comments-end) - the beginning and end of a multiline comment.
6. TextGadget(#Gadget, -1, 50, Width, Height, Text$) - the value "-1" means that the coordinate is taken from the previous element. You just need to change the value of the first top element so that the subsequent ones move by the same amount.
GadgetToolTip(-1, Text$) - uses previous element id (for all Get/Set functions).
7. ProgressOn, ProgressOff, ProgressSet, SplashImageOn, SplashOff, SplashTextOn - independent windows like InputRequester, but allow you to show progress and a splash screen when starting programs.
8. OnAutoItExitRegister - registers the function that is executed when the program terminates, no matter where it happens. For example, you need to free Windows resources that the program does not know about and cannot free, since they are not resources of the program itself.
9. Using "_" as a line continuation

Code: Select all

If MessageRequester("Overwrite?", "Overwrite?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes _
	And MessageRequester("Confident?", "Confident?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
	Debug "Yes"
EndIf
If MessageRequester("Overwrite?", "Overwrite?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes And _
	MessageRequester("Confident?", "Confident?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
	Debug "Yes"
EndIf
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Syntax suggestion in PureBasic

Post by Demivec »

There have been lots of suggestions to include features from other languages. If they were included they would make PurBeasic a dizzying patchwork quilt. There are still rough edges in the language that could benefit from something that would smooth things out.
I'm just going to give a brief opinion on each thing mentioned.

1. This is a useful idea, it just depends on the details.
2 . This makes sense at least as a natural extension of existing functionality.
3. Absolutely useless.
4. This is a useful idea but its usefulness is tied up in how it is implemented. I would even favor just sequential commas i.e. PeekS(*mem, , #PB_UTF8), which might be only the result of typos.
5. We need a block comment indicator.
6. This seems full of problems.
7. This seems like something that is from the world view of AutoIt and it would be just extra baggage in PureBasic.
8. This seems to have very limited usefulness. I'm just not seeing it.
9. Having a designated continuation character would help with reafability but '_' is a legal variable name.
AZJIO
Addict
Addict
Posts: 2217
Joined: Sun May 14, 2017 1:48 am

Re: Syntax suggestion in PureBasic

Post by AZJIO »

Demivec wrote: Mon Jul 22, 2024 6:32 am 3. Absolutely useless.
https://www.purebasic.fr/english/viewto ... 45#p617645
You won't have to duplicate the second block of code because you automatically continue it.
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Syntax suggestion in PureBasic

Post by Demivec »

AZJIO wrote: Mon Jul 22, 2024 6:52 am
Demivec wrote: Mon Jul 22, 2024 6:32 am 3. Absolutely useless.
https://www.purebasic.fr/english/viewto ... 45#p617645
You won't have to duplicate the second block of code because you automatically continue it.
After reviewing your link and much deep thought I amend my previous statement to now read:
3. Mostly absolutely useless. (Reference: Hitchhiker's Guide to the Galaxy :) )


I think there would not be any great harm in adding a command to allow explicit fallthrough from one case statement's code to the code in the next case. However, I think the usefulness or actual use of such a statement would be very infrequent. IMHO, Alternate approaches cover the perceived need adequately enough most of the time.

Just to show I'm a honest solution finder here is a link: https://www.purebasic.fr/english/viewtopic.php?p=529042#p529042
Post Reply