Got an idea for enhancing PureBasic? New command(s) you'd like to see?
the.weavster
Addict
Posts: 1576 Joined: Thu Jul 03, 2003 6:53 pm
Location: England
Post
by the.weavster » Wed Jan 04, 2023 6:34 pm
So that
Code: Select all
Result = OpenFile(#PB_Any, Filename$)
If Result
; do work with Result
EndIf
... could be abbreviated to
Code: Select all
If Result := OpenFile(#PB_Any, Filename$)
; do work with Result
EndIf
jacdelad
Addict
Posts: 1993 Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa
Post
by jacdelad » Wed Jan 04, 2023 7:24 pm
Searching for the keyword "walrus" would have shown a thread where I suggested that a while ago:
viewtopic.php?p=587146#p587146
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Little John
Addict
Posts: 4779 Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany
Post
by Little John » Wed Jan 04, 2023 7:37 pm
I like walruses.
Oso
Enthusiast
Posts: 595 Joined: Wed Jul 20, 2022 10:09 am
Post
by Oso » Wed Jan 04, 2023 8:23 pm
This would have been nice tonight. It's 2 am and I'm in the process of going through code converting from OpenFile(n, to OpenFile(#PB_Any, because the software will be moving to 'multiple-user'
nsstudios
Enthusiast
Posts: 309 Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:
Post
by nsstudios » Wed Jan 04, 2023 8:33 pm
Yes please!
It can be kinda done in inlineC, though.
Code: Select all
Define t1, t2
; f_testfunc1() and f_testfunc2() not found if not procedureDll
ProcedureDLL testfunc1(): ProcedureReturn 123: EndProcedure
ProcedureDLL testfunc2(): ProcedureReturn 321: EndProcedure
!if((v_t1=f_testfunc1())==(v_t2=f_testfunc2())) {
;do something
!}
Debug t1
Debug t2
yuki
Enthusiast
Posts: 101 Joined: Sat Mar 31, 2018 9:09 pm
Post
by yuki » Tue Sep 12, 2023 7:27 pm
This would be quite handy especially if it defines the LHS so
EnableExplicit is satisfied.
It might simplify this common pattern slightly (less one little line):
Code: Select all
Define x
For x = 0 To limit
; ...
Next
Into:
Though, I might put forward an alternative syntax suggestion:
Code: Select all
For Define x = 0 To limit
; ...
Next
If Define result = OpenFile(#PB_Any, filename$)
; do work with result
EndIf
(more verbose but it avoids ":" taking on another responsibility alongside its existing use in subroutines and continuation. it's at least hard to miss)
Caronte3D
Addict
Posts: 1355 Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe
Post
by Caronte3D » Tue Sep 12, 2023 7:43 pm
The ":=" reminds me the old Delphi/Pascal days
nsstudios
Enthusiast
Posts: 309 Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:
Post
by nsstudios » Tue Sep 12, 2023 8:26 pm
I like the define way too.
Sadly I can't imagine PB getting syntax updates, but one can dream I guess.
Little John
Addict
Posts: 4779 Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany
Post
by Little John » Tue Sep 12, 2023 11:45 pm
Let Define alone, please!
Lord
Addict
Posts: 900 Joined: Tue May 26, 2009 2:11 pm
Post
by Lord » Wed Sep 13, 2023 7:14 am
Please stay BASIC.
There are too many influences from other programming languages lately.
the.weavster
Addict
Posts: 1576 Joined: Thu Jul 03, 2003 6:53 pm
Location: England
Post
by the.weavster » Wed Sep 13, 2023 9:00 am
Caronte3D wrote: Tue Sep 12, 2023 7:43 pm
The ":=" reminds me the old Delphi/Pascal days
The idea was really from
Python PEP 572
yuki wrote: Tue Sep 12, 2023 7:27 pm
Though, I might put forward an alternative syntax suggestion:
Code: Select all
If Define result = OpenFile(#PB_Any, filename$)
; do work with result
EndIf
If an alternative syntax is considered to be more BASIC that's cool, I'd just like to see that pattern, which is common in PB, compressed.
BarryG
Addict
Posts: 4135 Joined: Thu Apr 18, 2019 8:17 am
Post
by BarryG » Wed Sep 13, 2023 9:59 am
Lord wrote: Wed Sep 13, 2023 7:14 am Please stay BASIC.
There are too many influences from other programming languages lately.
100% agreed. I chose PureBasic for BASIC.
the.weavster
Addict
Posts: 1576 Joined: Thu Jul 03, 2003 6:53 pm
Location: England
Post
by the.weavster » Wed Sep 13, 2023 11:15 am
BarryG wrote: Wed Sep 13, 2023 9:59 am
Lord wrote: Wed Sep 13, 2023 7:14 am Please stay BASIC.
There are too many influences from other programming languages lately.
100% agreed. I chose PureBasic for BASIC.
jacdelad
Addict
Posts: 1993 Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa
Post
by jacdelad » Wed Sep 13, 2023 11:56 am
We are asking for an addition, not a replacement. Nobody would be forced to use it...
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Little John
Addict
Posts: 4779 Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany
Post
by Little John » Wed Sep 13, 2023 12:39 pm
jacdelad wrote: Wed Sep 13, 2023 11:56 am
Nobody would be forced to use it...
Well, that depends on your definition of “usage”.