Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"WITH" keyword
#1
Have there been any thoughts on making a "WITH" keyword for QB64 for assigning values to UDT members?
Tread on those who tread on you

Reply
#2
Hi Spriggsy - would that create the Type and dimension the variables or how do you see that working with UDT?
Reply
#3
`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.
Reply
#4
Personally, I'd rather see Alias expanded.

Alias verylongvariablenamebutitsshorterjustforthisexample AS foo

foo.x =
foo.y =
Reply
#5
If we do aliases, then the next logical step would be aliasing variable types as well.
Alias UNSIGNED LONG AS DWORD
Tread on those who tread on you

Reply
#6
(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 !!
Reply
#7
(10-20-2023, 04:18 PM)RhoSigma Wrote: STOP TRYING TO FAKE OTHER LANGUAGES !!

no
Tread on those who tread on you

Reply
#8
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"
Reply
#9
(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?
b = b + ...
Reply
#10
how'd that post get doubled up? this too???
b = b + ...
Reply




Users browsing this thread: 5 Guest(s)