September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,33 +0,0 @@
var1$ = "Global1"
var2$ = "Global2"
PRINT "Before function call:"
PRINT "var1$ = """ var1$ """"
PRINT "var2$ = """ var2$ """"
PROCtestscope(var1$)
PROCtestscope(var1$)
PRINT "After function call:"
PRINT "var1$ = """ var1$ """"
PRINT "var2$ = """ var2$ """"
END
DEF PROCtestscope(var2$)
PRINT "On entry to function:"
PRINT "var1$ = """ var1$ """"
PRINT "var2$ = """ var2$ """"
LOCAL var1$
PRIVATE var2$
PRINT "After LOCAL/PRIVATE:"
PRINT "var1$ = """ var1$ """"
PRINT "var2$ = """ var2$ """"
var1$ = "Local"
var2$ = "Private"
PRINT "After assignments:"
PRINT "var1$ = """ var1$ """"
PRINT "var2$ = """ var2$ """"
ENDPROC

View file

@ -0,0 +1,40 @@
define g(a) {
auto b
b = 3
"Inside g: a = "; a
"Inside g: b = "; b
"Inside g: c = "; c
"Inside g: d = "; d
a = 3; b = 3; c = 3; d = 3
}
define f(a) {
auto b, c
b = 2; c = 2
"Inside f (before call): a = "; a
"Inside f (before call): b = "; b
"Inside f (before call): c = "; c
"Inside f (before call): d = "; d
x = g(2) /* Assignment prevents output of the return value */
"Inside f (after call): a = "; a
"Inside f (after call): b = "; b
"Inside f (after call): c = "; c
"Inside f (after call): d = "; d
a = 2; b = 2; c = 2; d = 2
}
a = 1; b = 1; c = 1; d = 1
"Global scope (before call): a = "; a
"Global scope (before call): b = "; b
"Global scope (before call): c = "; c
"Global scope (before call): d = "; d
x = f(1)
"Global scope (before call): a = "; a
"Global scope (before call): b = "; b
"Global scope (before call): c = "; c
"Global scope (before call): d = "; d

View file

@ -0,0 +1,13 @@
public //visible to anything.
protected //visible to current class and to derived classes.
internal //visible to anything inside the same assembly (.dll/.exe).
protected internal //visible to anything inside the same assembly and also to derived classes outside the assembly.
private //visible only to the current class.
//Modifier | Class | Assembly | Subclass | World
//--------------------------------------------------------
//public | Y | Y | Y | Y
//protected internal | Y | Y | Y | N
//protected | Y | N | Y | N
//internal | Y | Y | N | N
//private | Y | N | N | N

View file

@ -0,0 +1,21 @@
public interface IPrinter
{
void Print();
}
public class IntPrinter : IPrinter
{
void IPrinter.Print() { // explicit implementation
Console.WriteLine(123);
}
public static void Main() {
//====Error====
IntPrinter p = new IntPrinter();
p.Print();
//====Valid====
IPrinter p = new IntPrinter();
p.Print();
}
}

View file

@ -0,0 +1,22 @@
// version 1.1.2
class SomeClass {
val id: Int
companion object {
private var lastId = 0
val objectsCreated get() = lastId
}
init {
id = ++lastId
}
}
fun main(args: Array<String>) {
val sc1 = SomeClass()
val sc2 = SomeClass()
println(sc1.id)
println(sc2.id)
println(SomeClass.objectsCreated)
}

View file

@ -0,0 +1,10 @@
forward function localf() -- not normally necesssary, but will not harm
forward global function globalf() -- ""
function localf()
return 1
end function
global function globalf()
return 2
end function

View file

@ -0,0 +1,5 @@
include somefile.e as xxx
-- alternatively, within somefile.e:
namespace xxx -- (only supported in Phix for compatibility with OpenEuphoria)
res = xxx:globalf() -- call a global function named globalf, specifically the one declared in somefile.e