- Reaction score
- 333
Are you sure it is sensible to write this in C (going by your original post)?
Why write the definition first?? Shouldn't you be writing a simple compiler that compiles a simple script instead to start with??
Like:
Code:func CallMe (int a, unit b) [bool] endfunc converts as function CallMe takes integer a, unit b returns boolean endfunction
This [bool] is odd.
Real programming languages uses
bool CallMe (int a, unit b) {}
This isn't a programming language though.
This isn't a programming language though.
In what way isn't it a programming language?
Namespaces are vJASS libraries, and have essentially the same features.
Example:
namespace HelloWorld
globals
private constant string msg = "Hello World!" // Why global? I have no idea...
endglobals
function Init takes nothing returns nothing // Init is automatically called. No need to declare the initializer manually.
call BJDebugMsg(msg)
endfunction
endnamespace
If we want to require other namespaces...
namespace Hello World
globals
private constant string msg = "Hello World!"
endglobals
function helloworld takes nothing returns nothing
call BJDebugMsg(msg)
endfunction
endnamespace
namespace HelloWorld2 requires HelloWorld
function Init takes nothing returns nothing
call helloworld() // this is completely valid, since this namespace requires the other one.
endfunction
endnamespace
Care to shed the [LJASS]globals[/LJASS] keyword?JASS:globals private constant string msg = "Hello World!" // Why global? I have no idea... endglobals
...
Opinions?
private constant string msg = "Hello World!" // Why global? I have no idea...
> or do you have something else planned for that?
Nope. I just don't like it. Namespace makes more sense anyway.
library HelloWorld {
private constant string msg = "Hello World!"
public void display() {
BJDebugMsg(msg)
}
Initializer { //The initializer is automatically called. They are automatically private, and do not take/return any arguments.
BJDebugMsg(msg)
}
}
//If we want to use other libraries/packages/namespaces
library useHelloWorld
include HelloWorld
Initializer {
display()
}
}
space ha
endspace
//No need to type for initialiser, auto search for onInit as initializer.
//all functions/variables are private as default.
func Hello (string s) -> nothing
BJDebugMsg(s)
endfunc
//Function example.
set x = y
//Setting variables.
space ee
real x = 60.
//No need to use "globals" at here. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" />
//It will be private as mentioned above.
endspace