const SLANG_UTILITY = 1;

/*
m: Value to print

Prints a value to the console if available or alerts if not
*/
function log(m){
	if (is_set(console)){
		console.log(m);
	}else{
		alert(m);
	}
}


/*
v: Value to check

Returns True if value passed is set, False otherwise
*/
function is_set(v){
	return type(v) != 'undefined';
}

/*
obj : Object to check for property on
prop: Name of property to check for
def : Default value to return if prop is not found

Returns the value of obj property defined by prop, if def is passed, it is
returned on failure, otherwise null is returned.
*/
function property(obj, prop, def){
	if (is_set(obj[prop])){
		return obj[prop];
	} else {
		if (is_set(def)){
			return def;
		} else {
			return null;
		}
	}
}

/*
v : value to get type for

Functional equivalent of the typeof operator, returns argument's type.
*/
function type(v){
	return typeof v;
}
