QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: jack on March 29, 2019, 02:13:59 pm
-
is there a way to declare a type alias?
like TYPE REAL AS DOUBLE
DIM X AS REAL would be the same as DIM X AS DOUBLE
-
Nope.
-
thanks for the reply FellippeHeitor
-
Sorry I don't agree
you can respecting the TYPE syntax lke showed here http://qb64.org/wiki/TYPE (http://qb64.org/wiki/TYPE) and adoptin the dot as your second best friend.
PRINT " Double ";c;
" Real ";Argh.a
Thanks for reading
-
The problem with @TempodiBasic's "solution" is that it dishonors the querent's intent. While it may work from a 'machine' point of view - that is, the structure REAL defined by the TYPE may look in memory to be identical to a DOUBLE - it does not preserve the syntax that the querent was suggesting.
QB64 does not seem to have a preprocessor the way that most C compilers do (although the underlying C compilation may have one), but if it did, types could be aliased with (for example) #DEFINE REAL DOUBLE
-
@Freetrav
let me explain my previous response
1. I agree with you that my solution is more a provocation that uses a workaround to arrive where the querent claims to go than an effective solution.
2. taking a more general case in that the coder wants to DUPLICATE the keyword of a fundamental TYPE of data of the language:
from my little point of experience and point of view I cannot imagine in what the BASIC (a Procedural Language of Programming ) can be empowered by this kind of performance (duplication of the token keyword that the human uses to write code and the parser uses to translate the code for compiler).
Surely this my affirmation doesn't mean that jack's question is an error.
3. about preprocessor: fantastic idea! I seem to remember for RapidQ the community built a preprocessor to manage more extentions of the language that the same community brought on over in the time. It can be an idea for new clever programmers to create a new utility for QB64 like vWatch, InForm, GM64, those of Ashis, Unseen, David, RhoSigma and so more others that now I don't remember (sorry for an unwanted exclusion).