• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Feedback] There are something still miss in lesson 1

Status
Not open for further replies.
Level 5
Joined
Oct 13, 2010
Messages
84
First: Reference variable
Since i'm a coder, i still remember when i learn about variable: i must learn what is reference var and what is storage var.

JASS:
globals
integer a
integer b
endglobals
function SetBValue takes integer i returns nothing
     set a=i
     set b=a
     set i=i+1
endfunction

In some program languages, a is storage var, b is reference var.
And if the storage var (a) changes, the reference var (b) changes too.
However, in jass, both a and b is storage var! Then rewrite a with the other integer does not change b

And what about i?
Simple test:
JASS:
function TestSetValue takes nothing returns nothing
    local integer test=1
    call SetBValue(test)
    call BJDebug(I2S(test))
endfunction

The integer displays it's 1.
So the basic law here is:
- JASS have no reference variable.
Althought it's very simple, we still need to know that! Because it's basic and it has utmost influence!

Second: How to convert a variable to another type?
Like Nes said, there are native types and non-native types
the list of primitives would include
boolean
integer
real
code
handle
string

I2R
I2S
R2I
R2S
S2I
S2R
2 -> 2.03 -> "3"2.8 -> 22.1 -> "2.100""3.12345" -> 3"5.123456" -> 5.123

And something is more interesting:
JASS:
function TestEvaluate takes nothing returns nothing
    local integer test=SetBValue
    call BJDebug(I2S(test))
    set test=abcfunc
    call BJDebug(I2S(test))
endfunction
Result is:
1
0

And advance knowledge with the types extends native type:
Ex:
native function GetHandleId takes handle h returns integer
can use like this
call GetHandleId(TriggerUnit)
 
vuongkk, I wrote that map, lol... not mag

The only thing mag did was put it up in a post

You start getting into conversions and what not in week #2

Retrieving values in functions is too much for week #1.

In week #1, what's important is understanding variables, understanding memory, and understanding how to call functions as well as the difference between functions and natives.

It's way*** too early to be introducing the topics you mentioned for week #1
 
But the title isn't variable, that was mag's blunder calling it variables, lol


the variables portion of the map only introduce variables


also, I don't think that references and values ever need to be covered, heh

values are introduced very well at the start, and you also start to get a feeling for pointers, which become much more important later on when you start doing structs ^)^
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
lol, it was actually wrote in one book that total newb who never worked with programming before would think that if I set b to a, b will change when I change a.
You doesnt sound like a newb, you aound like a experienced programmer
Jass is too simple and there are no pointers or references in Jass afaik
nes, tho I think conversations could be included in week 1 because its week between each of them
its like in our school, for every little thing(1D arrays and 2D arrays split to two weeks) we have 2 hours, but we only have 2 of them in one week which is sad
 
Level 5
Joined
Oct 13, 2010
Messages
84
Actually, if i don't test, i will misunderstand in case variable i.
At least, add the First: Reference variable like advance in any week which you think it's suitable.
I subscribed jass class and i'm going to follow you to the end :D
 
Status
Not open for further replies.
Top