Language Core & OOPv0.12.0
Full OOP, Generic Classes/Interfaces, Module Visibility & SOLID
Monomorphized Generic IRepository<T>/BaseRepository<T>, module private/ozel visibility, class/interface, encapsulation, and SOLID layering.
9 min readUpdated: v0.13.0 Reference
Enterprise OOP & Generic Classes — At Native ISO C17 Speed
HADID v0.12.0 combines full object-oriented programming with compile-time generic monomorphization and module-level encapsulation:
- User-Defined Generic Classes & Interfaces (v0.12.0): Write reusable
interface IRepository<T>,class BaseRepository<T> : IRepository<T>,Box<T>, andPair<K, V>— specialized at compile time into zero-overhead ISO C17 structs and vtables. - Visibility & Default Access Rules (v0.12.0):
- Top-level declarations and class members default to
publicwhen omitted (100% backwards-compatible). - Mark module-internal helpers
private/ozel(private fn,private const,private struct,private class,private interface,private enum) — cross-module access fails at compile time. - Inside classes,
public,private,protected, andreadonlyare strictly enforced at compile time. - Single Inheritance + Multi-Interface:
class UserRepository : BaseRepository<User>andclass Engineer : Person, IGreeter, ITagged. - Zero-Overhead ISO C17 Codegen: Derived classes embed their base struct as their first field (ISO C17 standard-layout prefix); virtual dispatch uses static vtables and interfaces use stack-allocated
{ data, vtable }fat pointers.
Live Generic Box<T> & Pair<K, V> Example
hadid · EN
class Box<T> {
private value: T;
public Box(v: T) {
this.value = v;
}
public fn get(): T {
return this.value;
}
}
class Pair<K, V> {
public readonly key: K;
public readonly value: V;
public Pair(k: K, v: V) {
this.key = k;
this.value = v;
}
}
let b1 = new Box<i32>(42);
let b2 = new Box<string>("Hadid v0.12");
let p = new Pair<string, i64>("version", 12);
print($"Box={b1.get()} · {b2.get()} · Pair={p.key}:{p.value}");Live OOP & Interface Example (English)
hadid · EN
interface INotifier {
fn send(message: string): string;
}
class Entity {
protected readonly id: i32;
public Entity(id: i32) {
this.id = id;
}
public virtual fn summary(): string {
return $"Entity#{this.id}";
}
}
class Channel : Entity, INotifier {
private readonly name: string;
public Channel(id: i32, name: string) : base(id) {
this.name = name;
}
public override fn summary(): string {
return $"{base.summary()}:{this.name}";
}
public fn send(message: string): string {
return $"[{this.name}] {message}";
}
}
fn dispatch(notifier: INotifier, msg: string): void {
print(notifier.send(msg));
}
let email = new Channel(7, "Email");
print(email.summary());
dispatch(email, "Hadid v0.12 is live!");