Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
14
Task/Introspection/AWK/introspection.awk
Normal file
14
Task/Introspection/AWK/introspection.awk
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# syntax: GAWK -f INTROSPECTION.AWK
|
||||
BEGIN {
|
||||
if (PROCINFO["version"] < "4.1.0") {
|
||||
print("version is too old")
|
||||
exit(1)
|
||||
}
|
||||
bloop = -1
|
||||
if (PROCINFO["identifiers"]["abs"] == "user" && bloop != "") {
|
||||
printf("bloop = %s\n",bloop)
|
||||
printf("abs(bloop) = %s\n",abs(bloop))
|
||||
}
|
||||
exit(0)
|
||||
}
|
||||
function abs(x) { if (x >= 0) { return x } else { return -x } }
|
||||
|
|
@ -1,22 +1,31 @@
|
|||
import std.compiler, std.math;
|
||||
// Some module-level variables (D doesn't have a global scope).
|
||||
immutable x = 3, y = 100, z = 3_000;
|
||||
short w = 1; // Not an int, must be ignored.
|
||||
immutable s = "some string"; // Not an int, must be ignored.
|
||||
|
||||
void main() {
|
||||
import std.compiler, std.math, std.traits;
|
||||
|
||||
// Compile-time constants of the compiler version:
|
||||
static if (version_major < 2 && version_minor > 50) {
|
||||
// this prevents further compilation
|
||||
static assert(false, "I can't cope with this compiler version");
|
||||
} else {
|
||||
pragma(msg, "The compiler version is acceptable.");
|
||||
}
|
||||
static assert(version_major > 1 && version_minor > 50,
|
||||
"I can't cope with this compiler version.");
|
||||
|
||||
immutable bloop = 10;
|
||||
|
||||
// To check if something compiles:
|
||||
//static if (__traits(compiles, bloop.abs)) {
|
||||
static if (__traits(compiles, abs(bloop))) {
|
||||
static if (__traits(compiles, bloop.abs)) {
|
||||
pragma(msg, "The expression is compilable.");
|
||||
auto x = bloop.abs;
|
||||
} else {
|
||||
pragma(msg, "The expression can't be compiled.");
|
||||
}
|
||||
|
||||
import std.stdio;
|
||||
immutable s = 10_000; // Not at module scope, must be ignored.
|
||||
|
||||
int tot = 0;
|
||||
/*static*/ foreach (name; __traits(allMembers, mixin(__MODULE__)))
|
||||
static if (is(int == Unqual!(typeof(mixin("." ~ name)))))
|
||||
tot += mixin("." ~ name);
|
||||
writeln("Total of the module-level ints (could overflow): ", tot);
|
||||
}
|
||||
|
|
|
|||
22
Task/Introspection/PL-I/introspection-2.pli
Normal file
22
Task/Introspection/PL-I/introspection-2.pli
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
*process source attributes options m or(!);
|
||||
/*********************************************************************
|
||||
* 02-11.2013 Walter Pachl
|
||||
* I modified this to run on my Windows PL/I
|
||||
*********************************************************************/
|
||||
v: Proc Options(main);
|
||||
%version: Proc Returns(char);
|
||||
Dcl res char;
|
||||
res=sysversion;
|
||||
Return(''''!!res!!'''');
|
||||
%End;
|
||||
%Act version;
|
||||
Dcl s char(31) Init('');
|
||||
s=version;
|
||||
if substr(S,15,3) < '7.5' then Do;
|
||||
put Skip list('Version of compiler ('!!substr(S,15,3)!!
|
||||
') is too old');
|
||||
stop;
|
||||
End;
|
||||
Else
|
||||
Put Skip List('Version is '!!s);
|
||||
End
|
||||
|
|
@ -3,7 +3,7 @@ if testxyz() then say 'function XYZ not found.'
|
|||
exit
|
||||
|
||||
testxyz: signal on syntax
|
||||
y='XYZ'(123)
|
||||
call XYZ
|
||||
return 0
|
||||
|
||||
syntax: return 1
|
||||
|
|
|
|||
9
Task/Introspection/Scala/introspection.scala
Normal file
9
Task/Introspection/Scala/introspection.scala
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
object VersCheck extends App {
|
||||
val minimalVersion = 1.7
|
||||
|
||||
val vers = System.getProperty("java.specification.version");
|
||||
println(if (vers.toDouble >= minimalVersion) "YAY!" else s"Must use Java >= $minimalVersion");
|
||||
|
||||
val bloop = Option(-42)
|
||||
if (bloop.isDefined) bloop.get.abs
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue