| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | class B | x y | { | 
					
						
							| 
									
										
										
										
											2023-12-02 03:35:59 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | class X :: B | a b | { | 
					
						
							|  |  |  | 	fun :* new(t) { | 
					
						
							| 
									
										
										
										
											2023-12-02 03:35:59 +09: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; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | 	fun print() { | 
					
						
							| 
									
										
										
										
											2023-12-02 03:35:59 +09:00
										 |  |  | 		self.c (+ self.a self.b); | 
					
						
							|  |  |  | 		printf "a=%d b=%d\n" self.a self.b; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2024-03-14 23:26:38 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | class X { | 
					
						
							|  |  |  | 	fun :* xxx() { | 
					
						
							| 
									
										
										
										
											2024-04-05 01:26:02 +09:00
										 |  |  | 		return X; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | 	fun :* qqq() { | 
					
						
							| 
									
										
										
										
											2024-04-05 01:26:02 +09:00
										 |  |  | 		return "hello" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | 	fun String:length()  { ##ERROR: syntax error - function name not valid | 
					
						
							| 
									
										
										
										
											2024-04-05 01:26:02 +09:00
										 |  |  | 		return (str.length self) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-03-14 23:26:38 +09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-05 01:26:02 +09:00
										 |  |  | --- | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | class X { | 
					
						
							|  |  |  | 	fun :* xxx() { | 
					
						
							| 
									
										
										
										
											2024-04-05 01:26:02 +09:00
										 |  |  | 		return X; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | 	fun :* qqq() { | 
					
						
							| 
									
										
										
										
											2024-04-05 01:26:02 +09:00
										 |  |  | 		return "hello" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## this will trigger a runtime error as J isn't a class name | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | fun J:ccc()  { ##ERROR: exception not handled | 
					
						
							| 
									
										
										
										
											2024-04-05 01:26:02 +09:00
										 |  |  | 	return 999 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-05-26 23:18:26 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | ## this must not be very useful as Array is an index item | 
					
						
							|  |  |  | ## and the clase instantiation method can't specify the size | 
					
						
							|  |  |  | ## you can't place an item in the arrya at all. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | fun Array:*boom() { | 
					
						
							|  |  |  |       arr.put self 0 10 ##ERROR: exception not handled | 
					
						
							|  |  |  |       printf "%O" self | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Array:boom |