- Proposal: SE-NNNN
- Authors: Robert Widmann, Jaden Geller
- Review Manager: TBD
- Status: Awaiting review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # UI framework rules for SwiftUI | |
| 1. State Management: | |
| - Use `@Observable` for reference types holding business logic and app state. | |
| - Use `@Bindable` properties within @Observable classes so SwiftUI views can bind directly to them. | |
| - Avoid `@State` for view model observation, rely on `let model: MyModel` instead. | |
| - Pass dependencies via initialisers rather than as global singletons. | |
| - Use `@Environment` for app-wide or large-scope states. | |
| - `@State` is only for view-local state. | |
| - Use `@Binding` only if necessary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @import Foundation; | |
| @import CoreGraphics; | |
| typedef struct __attribute__((objc_boxable)) CGPoint CGPoint; | |
| typedef struct __attribute__((objc_boxable)) CGSize CGSize; | |
| typedef struct __attribute__((objc_boxable)) CGRect CGRect; | |
| typedef struct __attribute__((objc_boxable)) CGVector CGVector; | |
| int main(int argc, const char * argv[]) { | |
| @autoreleasepool { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| struct Monoid<A> { | |
| let zero: A | |
| let append: (A, A) -> A | |
| } | |
| let additive = Monoid(zero: 0, append: +) | |
| let multiplicative = Monoid(zero: 1, append: *) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*<?php | |
| //*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s", | |
| //\u000A\u002F\u002A | |
| class PhpJava { | |
| static function main() { | |
| echo(//\u000A\u002A\u002F | |
| "Hello World!"); | |
| }} | |
| //\u000A\u002F\u002A | |
| PhpJava::main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// An operator is given by a list of arities, where each element indicates the number of | |
| /// variables bound by the operator at that position and the length of the list determines the | |
| /// number of variables the operator accepts. The full generalization of arity is called | |
| /// the operator's "valence". | |
| /// | |
| /// For example, if I have a little calculator language with let-bindings, its operators | |
| /// would look like this: | |
| /// | |
| /// | |
| /// enum CalcOps : Operator { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private class MyArrayBuffer<Element>: ManagedBuffer<Int,Element> { | |
| func clone() -> MyArrayBuffer<Element> { | |
| return self.withUnsafeMutablePointerToElements { elements -> MyArrayBuffer<Element> in | |
| return MyArrayBuffer<Element>.create(self.allocatedElementCount) { newBuf in | |
| newBuf.withUnsafeMutablePointerToElements { newElems->Void in | |
| newElems.initializeFrom(elements, count: self.value) | |
| } | |
| return self.value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Cocoa | |
| protocol Thing { | |
| var x: String {get} | |
| init(s: String) | |
| } | |
| class Foo: Thing { | |
| let x: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare function require(module:string):any; | |
| declare var process:any; | |
| var readline = require('readline'); | |
| var fs = require('fs'); | |
| type brainfuckDone = (char : string) => void; | |
| type brainfuckInput = (done : brainfuckDone) => void; | |
| function brainfuck(tokens : string[], inp : brainfuckInput) { |
NewerOlder