-- Simple object system with automatic reference counting
type Object': refCount=>Integer;
type Object => *Object';
Object.init: self;
Object.dealloc: free self;
Object.retain: incr refCount;
Object.release: if ((decr refCount) = 0) then {
@interface CYRPNCalculator : NSObject { | |
double _stack[1024]; | |
uint16_t _stackHeight; | |
} | |
@end | |
@implementation CYRPNCalculator | |
- (double)push:(double const)n | |
{ | |
return _stack[_stackHeight++] = n; | |
} |
@RPN { | |
accessor: #stack initialValue: [] | |
- push: n `@stack push: n; last` | |
- add `self push: (@stack pop + @stack pop)` | |
- sub { | |
t = @stack pop | |
^self push: (@stack pop - t) | |
} |
SELECT COUNT(*), DATE(cancel_date) | |
FROM transactions | |
WHERE DATE(cancel_date) IN ( | |
SELECT DATE(charge_date) as date FROM transactions | |
UNION | |
SELECT DATE(cancel_date) AS c FROM transactions WHERE NOT c ISNULL | |
) | |
GROUP BY DATE(cancel_date) |
#import "PSPadView.h" | |
#import "PSPadKontrolEvent.h" | |
#import "SekwenserAppDelegate.h" | |
#import "PadkontrolConstants.h" | |
#import <SnoizeMIDI/SnoizeMIDI.h> | |
@implementation PSPadView | |
@synthesize activeGroup=_activeGroup, fixedVelocity=_fixedVelocity; | |
- (void)padPressed:(PSPadKontrolEvent *)event |
% tranquil Tools/tqc.tq -dylib lib.tq -o test.dylib | |
% clang libtest.m -ltest -L. -rpath . -framework Foundation | |
% ./a.out | |
loaded | |
foo | |
HEY! | |
2013-03-01 03:07:09.267 a.out[38638:707] fromlib: <Klass: 0x7fab1240fe90> | |
% cat lib.tq | |
@Klass { | |
- init { "HEY!" print. self} |
ma source
interface Truthy: toBool => Void->Bool;
Bool.toBool: self;
macro #if cond => Truthy #then ifCase => Procedure #else: elseCase => Typeof ifCase:
[ifCase, elseCase][cond.toBool!]!;
macro #if cond => Truthy #then ifCase #else: elseCase => Typeof ifCase:
if cond then `ifCase` else `elseCase`;
export main: { argc(Integer32), argv(Integer8**) | | |
print "Hello world"; | |
0.upto argc-1 `i| print argv[i]`; | |
0 | |
} |
@Team { | |
initializer: [#name, #memberCount] | |
readers: [#name, #memberCount] | |
} | |
t = Team withName: #foo memberCount: 123 | |
t name print |
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
#define TestMain() int main(int argc, const char **argv) { \ | |
Class classes[4098]; \ | |
int classCount = objc_getClassList(classes, 4098); \ | |
for(int i = 0; i < classCount; ++i) { \ | |
if(class_getSuperclass(classes[i]) != [Spec class]) \ | |
continue; \ | |
NSLog(@"Running %@", classes[i]); \ |