The lang keyword can be used in a statement context to declare a block of code written in a programming language other than Sling. The syntax is as follows:

lang "languageName" {{{
	(this is code in the other language)
}}}

For example:

lang "objc" {{{
	MyObjectiveCClass* variable = [[MyObjectiveCClass alloc] init];
	[variable callMethod];
}}}

The language is specified so that the compiler may perform any necessary processing for the block of code, not for the purpose of performing conditional compilation. Since lang blocks are usually used to perform platform-specific functionality, they will normally be enclosed in IFDEF blocks:

IFDEF("target_iosoc") {
	lang "objc" {{{
		// objective-c implementation
	}}}
}
ELSE IFDEF("target_android") {
	lang "java" {{{
		// java implementation
	}}}
}
ELSE {
	ERROR("Not implemented")
}

The standard language names used include:

objc	Objective-C
java	Java
js	Javascript
cs	C#

Twitter Facebook LinkedIn Youtube Slideshare Github