This file contains 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
@propertyDelegate | |
public struct Binding<Value> { | |
public var value: Value { | |
get { getValue() } | |
nonmutating set { setValue(newValue) } | |
} | |
public init(getValue: @escaping () -> Value, setValue: @escaping (Value) -> Void) { | |
self.getValue = getValue | |
self.setValue = setValue |
This file contains 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 RaspberryPi | |
// Shutdown PWM1, clear FIFO | |
let pwm = try! PWM() | |
pwm[1].isEnabled = false | |
pwm.clearFifo() | |
// Stop the PWM clock | |
let clock = try! Clock() |
This is a test
PATH=$PATH:/opt/swift/bin
swift --version
Swift version 4.1 (swift-4.1-RELEASE)
Target: armv7-unknown-linux-gnueabihf
This file contains 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
2018-04-20 09:23:44,536 - Changing monitoring state from "Offline" to "Detecting serial port" | |
2018-04-20 09:23:44,572 - Serial port list: ['/dev/ttyACM0'] | |
2018-04-20 09:23:44,573 - Connecting to: /dev/ttyACM0 | |
2018-04-20 09:23:44,630 - Changing monitoring state from "Detecting serial port" to "Opening serial port" | |
2018-04-20 09:23:44,633 - Connected to: Serial<id=0x6b756a30, open=True>(port='/dev/ttyACM0', baudrate=250000, bytesize=8, parity='N', stopbits=1, timeout=10.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor | |
2018-04-20 09:23:44,634 - Changing monitoring state from "Opening serial port" to "Connecting" | |
2018-04-20 09:23:44,641 - Send: N0 M110 N0*125 | |
2018-04-20 09:23:45,696 - Recv: start | |
2018-04-20 09:23:45,705 - Recv: echo:Marlin 1.1.5 | |
2018-04-20 09:23:45,707 - Send: N0 M110 N0*125 |
This file contains 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
2018-04-19 21:07:57,068 - octoprint.server - INFO - --- Log roll over detected --------------------------------------------------- | |
2018-04-19 21:07:57,069 - octoprint.server - INFO - OctoPrint 1.3.8 | |
2018-04-19 21:07:57,071 - octoprint.plugin.core - INFO - 12 plugin(s) registered with the system: | |
| Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/announcements | |
| Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/corewizard | |
| CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/cura | |
| Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/discovery | |
| Firmware Updater (1.0.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_firmwareupdater | |
| Logging (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/logging | |
| OctoPi Support Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/octopi_support |
This file contains 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
2018-04-19 21:07:57,068 - octoprint.server - INFO - --- Log roll over detected --------------------------------------------------- | |
2018-04-19 21:07:57,069 - octoprint.server - INFO - OctoPrint 1.3.8 | |
2018-04-19 21:07:57,071 - octoprint.plugin.core - INFO - 12 plugin(s) registered with the system: | |
| Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/announcements | |
| Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/corewizard | |
| CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/cura | |
| Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/discovery | |
| Firmware Updater (1.0.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_firmwareupdater | |
| Logging (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/logging | |
| OctoPi Support Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/octopi_support |
This file contains 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
#if os(Linux) | |
import Glibc | |
#else | |
import Darwin | |
let O_SYNC: Int32 = 0 | |
#endif | |
import Dispatch |
An important goal in Swift is clarity at the point of use, this appears in the API Design Guidelines as a fundamental, but also pervades the design of the Swift language itself.
I think that removing the where
clause from Swift's for
loops reduces clarity.
It may be that there are other ways to express the same code result, but "only one way to do it" has never been a Swift goal that I'm aware of, and an identical result does not necessarily equate to an identical intent.
Consider the following, which was actually a source of brief confusion for me while reading some of your code.
Example 1:
This file contains 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
// | |
// SectionedFetchedResults.swift | |
// DungeonMaster | |
// | |
// Created by Scott James Remnant on 3/14/16. | |
// Copyright © 2016 Scott James Remnant. All rights reserved. | |
// | |
import CoreData | |
import Foundation |
NewerOlder