QB64 Phoenix Edition
"WITH" keyword - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: "WITH" keyword (/showthread.php?tid=2110)

Pages: 1 2


"WITH" keyword - SpriggsySpriggs - 10-19-2023

Have there been any thoughts on making a "WITH" keyword for QB64 for assigning values to UDT members?


RE: "WITH" keyword - Dimster - 10-20-2023

Hi Spriggsy - would that create the Type and dimension the variables or how do you see that working with UDT?


RE: "WITH" keyword - mnrvovrfc - 10-20-2023

`WITH` in Freebasic was designed to save wear and tear for the programmer, having to type in the UDT variable's name.

Instead of:
Code: (Select All)
verylongvariablenamebutitsshorterjustforthisexample(j).x = i
verylongvariablenamebutitsshorterjustforthisexample(j).y = j

could break it down in that other programming system as:
Code: (Select All)
with verylongvariablenamebutitsshorterjustforthisexample(j)
.x = i
.y = j
end with

Some people would like to be able to exclude the period because it looks funny in front of an identifier like that. It's actually this way in Pascal but it could produce many long hours in debugging trying to find something.

I was being facetious in the example but when working with many UDT's, like must be done in Windows API programming, this `WITH` was helpful to a few programmers in the BASIC dialects that have it. If QB64 could feature macro substitution in its "preprocessor", however, I think `WITH` wouldn't really be necessary. In fact macro substitution could help make the code more readable.


RE: "WITH" keyword - SMcNeill - 10-20-2023

Personally, I'd rather see Alias expanded.

Alias verylongvariablenamebutitsshorterjustforthisexample AS foo

foo.x =
foo.y =


RE: "WITH" keyword - SpriggsySpriggs - 10-20-2023

If we do aliases, then the next logical step would be aliasing variable types as well.
Alias UNSIGNED LONG AS DWORD


RE: "WITH" keyword - RhoSigma - 10-20-2023

(10-20-2023, 02:32 PM)SpriggsySpriggs Wrote: If we do aliases, then the next logical step would be aliasing variable types as well.
Alias UNSIGNED LONG AS DWORD

The only thing I've to say about:

STOP TRYING TO FAKE OTHER LANGUAGES !!


RE: "WITH" keyword - SpriggsySpriggs - 10-20-2023

(10-20-2023, 04:18 PM)RhoSigma Wrote: STOP TRYING TO FAKE OTHER LANGUAGES !!

no


RE: "WITH" keyword - SMcNeill - 10-20-2023

I don't care about faking other languages; all I want is a shorthand for typing junk.

ALIAS "_PRINTSTRING(" AS "??"

?? x, y), "Hello World"


Just as CONST does basic substitution, so does Alias, so that's just shorthand for:
_PRINTSTRING(x, y), "Hello World"


RE: "WITH" keyword - bplus - 10-20-2023

(10-20-2023, 05:25 PM)SMcNeill Wrote: I don't care about faking other languages; all I want is a shorthand for typing junk.

ALIAS "_PRINTSTRING(" AS "??"

?? x, y), "Hello World"


Just as CONST does basic substitution, so does Alias, so that's just shorthand for:
_PRINTSTRING(x, y), "Hello World"

I was doing that with editor I was building with old VB for DOS (very easy to build editors there BTW!)
All the long paragraphs in a variable name put on a list you could click to paste in.

(10-20-2023, 04:55 PM)SpriggsySpriggs Wrote:
(10-20-2023, 04:18 PM)RhoSigma Wrote: STOP TRYING TO FAKE OTHER LANGUAGES !!

no

+1 Who can happily pass up a great idea?


RE: "WITH" keyword - bplus - 10-20-2023

how'd that post get doubled up? this too???