Page 1 of 1

Change Define word to Let word

Posted: Sat Jun 03, 2006 7:25 pm
by Psychophanta
Let


Syntax
Let.<type> [<variable> [= <expression>], <variable> [= <expression>], ...]

Description

If no <variables> are specified, Let is used to change the default type for future untyped variables (including procedure parameters and interface method parameters). The initial default type is long (.l). Each variable can have a default value directly assigned to it.
Example:

d = e + f
Let.w
a = b + c

d, e and f will be created as long type variables, since there was no type specified. a, b and c will be signed word typed (.w) as no type is specified and the default type had been changed to the word type.

If variables are specified, Let only declares these variables as "defined type" and will not change the default type.
Example:

Let.b a, b = 10, c = b*2, d ; these 4 variables will be byte typed (.b)


Syntax
Let <variable>.<type> [= <expression>] [, <variable>.<type> [= <expression>], ...]

Description

Alternative possibility for the variable declaration using Let.
Example:

Let MyChar.c
Let MyLong.l
Let MyWord.w

Debug SizeOf(MyChar) ; will give 1 byte
Debug SizeOf(MyLong) ; will give 4 bytes
Debug SizeOf(MyWord) ; will give 2 bytes

Posted: Sat Jun 03, 2006 8:20 pm
by freak
How is 'Let' better than 'Define' ?

Posted: Sat Jun 03, 2006 8:23 pm
by Psychophanta
freak wrote:How is 'Let' better than 'Define' ?
It is more BASIC ;)

Posted: Sat Jun 03, 2006 10:39 pm
by Dare
IIRC, the LET keyword was redundant and meant to be used with equals in older basics. Eg:

Code: Select all

DIM A%
LET A% = 1
So I don't think it does the same thing as Define, which, well, defines a variable and IMO is superior to Dimming a scalar or LETting a variable.

So (sorry Pyschophanta) my vote is against LET. But then again, IIRC, "this is not a democracy." :D

Posted: Sat Jun 03, 2006 10:49 pm
by thefool
Dare is (afaik) 100% right about this..

Posted: Sun Jun 04, 2006 10:12 am
by Psychophanta
If you only see the syntax compatibility with other Basics, then you are 100% right.
But if you look at the meaning of the english word LET, you will see that it is ideal to replace the Define one.

Posted: Sun Jun 04, 2006 12:02 pm
by Franky

Code: Select all

Macro LET
   Define
EndMacro
Feature Added 8) [/code]

Posted: Sun Jun 04, 2006 12:05 pm
by Psychophanta
Franky wrote:

Code: Select all

Macro LET
   Define
EndMacro
Feature Added 8) [/code]

Code: Select all

Macro LET 
   Define 
EndMacro
Define.s="hi"
Feature not added 8)

Posted: Sun Jun 04, 2006 1:27 pm
by Dare
Um, you typed too fast, Pyscho! :). You can't assign a value to define, with or without a macro.

Code: Select all

Macro LET
   Define
EndMacro

;Define.s = "hi" <- invalid, same as Global.s="Hello" is invalid.

Define myString.s = "hi" 
LET myStr.s = "There"
Some definitions of Let: "to allow", "to assign", "to permit", "to lease", "to cause or make".