2023-12-01 18:35:59 +00:00
|
|
|
defclass B | x y | {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-02-03 16:57:53 +00:00
|
|
|
defclass X :: B | a b | {
|
2024-02-03 09:50:10 +00:00
|
|
|
defun :* new(t) {
|
2023-12-01 18:35:59 +00:00
|
|
|
| a |
|
|
|
|
set self.a t;
|
|
|
|
set a 100;
|
|
|
|
set self.b (* t 2);
|
|
|
|
|
|
|
|
set self.c (fun(b) { ##ERROR: syntax error - unknown class-level variable name
|
|
|
|
printf "xxxx [%d]\n" b;
|
|
|
|
});
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
defun print() {
|
|
|
|
self.c (+ self.a self.b);
|
|
|
|
printf "a=%d b=%d\n" self.a self.b;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-03-14 14:26:38 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
defclass X {
|
2024-04-04 16:26:02 +00:00
|
|
|
defun :* xxx() {
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
defun :* qqq() {
|
|
|
|
return "hello"
|
|
|
|
}
|
|
|
|
|
|
|
|
defun String:length() { ##ERROR: syntax error - function name not valid
|
|
|
|
return (str.length self)
|
|
|
|
}
|
2024-03-14 14:26:38 +00:00
|
|
|
}
|
|
|
|
|
2024-04-04 16:26:02 +00:00
|
|
|
---
|
|
|
|
defclass X {
|
|
|
|
defun :* xxx() {
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
defun :* qqq() {
|
|
|
|
return "hello"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## this will trigger a runtime error as J isn't a class name
|
|
|
|
defun J:ccc() { ##ERROR: exception not handled
|
|
|
|
return 999
|
|
|
|
}
|