Skip to content

Instantly share code, notes, and snippets.

@uliwitness
uliwitness / smalltalkbooleans.swift
Created August 28, 2017 06:58
Still fascinating how Smalltalk implements if/then/else. Basically it goes like this (in pseudo-Swift):
class BooleanClass {
void ifTrue(_ trueHandler: () -> Void, else falseHandler: () -> Void)
}
class TrueBooleanClass {
void ifTrue(_ trueHandler: () -> Void, else falseHandler: () -> Void) {
trueHandler()
}
}
@uliwitness
uliwitness / 1 cxxabi_shared error
Created July 29, 2017 09:33
llvm build errors
Creating symlinks
/Applications/CMake.app/Contents/bin/cmake -E cmake_symlink_library /Users/uli/Programming/llvm/build/Debug/lib/Debug/libc++abi.1.0.dylib /Users/uli/Programming/llvm/build/Debug/lib/Debug/libc++abi.1.dylib /Users/uli/Programming/llvm/build/Debug/lib/Debug/libc++abi.dylib
CMake Error: cmake_symlink_library: System Error: No such file or directory
CMake Error: cmake_symlink_library: System Error: No such file or directory
import Foundation
struct FooImages {
static let images = [UIImage(named:"foo1"), UIImage(named:"foo1")]
}
@uliwitness
uliwitness / main.cpp
Created April 7, 2017 21:46
Proof-of-concept for how one could implement Objective C's target/action paradigm in a static fashion in C++. Basically, the GeneratedWindow class would be what your UI builder (like Interface Builder) generates. Button would be in your application framework. ViewController and the main() function would be how you'd then use them.
//
// main.cpp
// CppTargetActionOutlets
//
// Created by Uli Kusterer on 07.04.17.
// Copyright © 2017 Uli Kusterer. All rights reserved.
//
#include <iostream>
#include <functional>
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#include <functional>
@class ObjCObject;
template<class p1type,class p2type>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="AppleScriptPropertyTest Terminology" xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="file://localhost/System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/>
<suite name="AppleScriptPropertyTest Suite" code="ASPT" description="AppleScriptPropertyTest Suite">
<cocoa name="ULIAppleScriptPropertyTestSuite"/>
<class-extension description="The App" extends="application">
<cocoa class="NSApplication"/>
<property name="boogaloo" code="ACTV" description="App&apos;s boogaloo prop." type="boolean">
<html>
<head>
<title>Streaming - Back Soon</title>
</head>
<body bgcolor="#00ff00">
<div id="message" style="font-size: 80pt; font-family: Helvetica; font-weight: bold; color: white; text-shadow: 2px 2px #000000;">
Back in <span id="timer">5:00</span> minutes
</div>
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
int* __nullable foo = NULL;
int& fooRef = *foo;
}
return 0;
}
struct eat_char_fcn
{
eat_char_fcn( struct eat_char_fcn (*inFun)( char currCh, xml_reader& reader, vector<shared_ptr<node>>& nod, attribute* att ) ) : function(inFun) {}
struct eat_char_fcn operator()( char currCh, xml_reader& reader, vector<shared_ptr<node>>& nod, attribute* att ) { return function(currCh,reader,nod,att); }
explicit operator bool() { return function != nullptr; }
struct eat_char_fcn (*function)( char currCh, xml_reader& reader, vector<shared_ptr<node>>& nod, attribute* att );
};
You can specify the underlying name for a C function the linker/compiler should actually use. If you use an existing
function's name, it will just let you refer to it with your prototype's name. If you define the function, it'll give
it that name. It even complains if a function of that name already exists. Tested with clang on a Mac, but AFAIK also
works in GCC. You can even use special characters in your function names, like you can do in assembly.