language question

Monkey Forums/Monkey Programming/language question

ReddoC(Posted 2012) [#1]
Can anyone explain me what means this:

?, $ and # in the following Method

Method DoSomthing?(var1$, var2#)
...
End

Thank you


ziggy(Posted 2012) [#2]
? means that the method returns a Boolan.
# means that the var2 is a Float
$ means that var1 is a string

Also, integers can be marked with a % character. This are datatype shortcuts, to make the code shorter to write.

All in all:

? is the same as :Bool
# is the same as :Float
% is the same as :Int
$ is the same as :String

It's common on blitz-esque languages like Monkey. Only a cosmetic thing.

In other words:

Local name$ = "hello world"

is the same as

Local name:String = "hello world"

and it can be applied to anything:
Field myField:Int = 34
Field myField% = 34

Function CalculateDistance#(point1%, point2%)
Function CalculateDistance:Float(point1:Int, point2:Int)

all of this are the same.


therevills(Posted 2012) [#3]
I always use these when quickly trying stuff out... and when coding BlitzMax BLIde changes them to the full version so it looks "neater" :)

Are these in the Monkey Wiki somewhere?


ziggy(Posted 2012) [#4]
I've been looking for it (I was willing to provide a link here) but haven't been able to find any reference to it.


ReddoC(Posted 2012) [#5]
Thank you ! It will help me to understand some code :)


SweCoder(Posted 2012) [#6]
Hey, newcomer here, but I remember this from old old Visual Basic code.. back in VB 3 or 4 I think.. since then I've moved on to stricter languages and had all but forgotten about it until I noticed this thread :).


DruggedBunny(Posted 2012) [#7]
I just went to add them to the docs, but it seems ziggy beat me to it!

http://blitz-wiki.appspot.com/Language_reference#types


Tibit(Posted 2012) [#8]
How does one add to the documentation?


therevills(Posted 2012) [#9]
I just went to add them to the docs, but it seems ziggy beat me to it!


I'd suggest bulking them up more as they currenty get lost, maybe under a subheading or something...

How does one add to the documentation?

Mere mortals cannot ;)


Tibit(Posted 2012) [#10]
Mere mortals cannot ;)

Haha. I helped create the original version, so does that not by definition make me a GOD in this context? And are gods not by default immortal somehow? ;)

However kidding aside :)

Any chance to be added to the help staff?


DruggedBunny(Posted 2012) [#11]
Just drop Mark an email -- blitzmunter AT gmail.com.


Tibit(Posted 2012) [#12]
Great, I sent him a mail :)