Upgrade to Pro — share decks privately, control downloads, hide ads and more …

偏見と妄想で語るスクリプト言語としての Swift / Swift as a Scriptin...

偏見と妄想で語るスクリプト言語としての Swift / Swift as a Scripting Language

Elvis Shi

May 18, 2022
Tweet

More Decks by Elvis Shi

Other Decks in Programming

Transcript

  1. 4XJGUͱ֤छεΫϦϓτݴޠͷಛ௃ ˞ɿυΩϡϝϯτΛಡ·ͳͯ͘΋*%&ͷαϙʔτͰ͋Δఔ౓ॻ͚Δ #BTI;TI 3VCZ 4XJGU จ๏͕୯७ ˚ ˓ ˓ ҆શੑ͕ߴ͍

    ʷ ˚ ˕ τϥΠˍΤϥʔ 
 ͠΍͍͢˞ ʷ ʷ ˓ ࣮ߦ଎౓͕଎͍˞ ˚ ˓ ˓ γΣϧίϚϯυͷ 
 ݺͼग़͕͠؆୯ ˕ ˓ ˚ ϥΠϒϥϦʔ͕๛෋  ˓ ˚ ˞ɿεΫϦϓτϑΝΠϧͱͯ͠ͷ࣮ߦ଎౓
  2. 4XJGU͔ΒγΣϧίϚϯυΛݺͼग़͢ʹ͸ import Foundation func execute(_ command: String) -> String {

    let task = Process() let pipe = Pipe() task.standardOutput = pipe task.standardError = pipe task.arguments = ["-cl", command] task.launchPath = "/bin/zsh" task.launch() let data = pipe.fileHandleForReading.readDataToEndOfFile() let output = String(data: data, encoding: .utf8)! return output } print(execute(#"echo "Hello, World! from Swift!""#), terminator: "") // Hello, World! from Swift!
  3. 4XJGUͱ֤छεΫϦϓτݴޠͷಛ௃ ˞ɿυΩϡϝϯτΛಡ·ͳͯ͘΋*%&ͷαϙʔτͰ͋Δఔ౓ॻ͚Δ 
 ˞ɿεΫϦϓτϑΝΠϧͱͯ͠ͷ࣮ߦ଎౓ #BTI;TI 3VCZ 4XJGU จ๏͕୯७ ˚ ˓

    ˓ ҆શੑ͕ߴ͍ ʷ ˚ ˕ τϥΠˍΤϥʔ 
 ͠΍͍͢˞ ʷ ʷ ˓ ࣮ߦ଎౓͕଎͍˞ ˚ ˓ ˓ γΣϧίϚϯυͷ 
 ݺͼग़͕͠؆୯ ˕ ˓ ˚ ϥΠϒϥϦʔ͕๛෋  ˓ ˚ 🤔
  4. ݁࿦ɿ4XJGU͸εΫϦϓτݴޠͱͯ͠΋࢖͑Δ w ྑ͔ͬͨ఺ w จ๏͸͔ͳΓ୯७ w ϑΝΠϧ୯ମͱͯ͠ͷ࣮ߦ଎౓͸ૣ͍ w ଞͷεΫϦϓτݴޠΑΓ͸Δ͔ʹߴ͍҆શੑ w

    վળ఺ w γΣϧͱͷ࿈ܞΛΑΓָʹͯ͠΄͍͠ w εΫϦϓτύοέʔδͱͯ͠ͷ࣮ߦ଎౓Λ্͛ͯ΄͍͠ w ϥΠϒϥϦʔʁͦΜͳͷԶΒϢʔβ͕ؤுΔ͍ͧ💪
  5. } var employedBy = "YUMEMI Inc." var job = "iOS

    Tech Lead" var favoriteLanguage = "Swift" var twitter = "@lovee" var qiita = "lovee" var github = "el-hoshino" var additionalInfo = """ ࣾ಺ϏσΦձٞͰ Vzoomer ૿΍͠·ͨ͠ʂ """ final class Me: Developable, Talkable {
  6. ࢀߟ w IUUQTFOXJLJQFEJBPSHXJLJ4XJGU@ QSPHSBNNJOH@MBOHVBHF  w IUUQTFOXJLJQFEJBPSHXJLJ4DSJQUJOH@MBOHVBHF w IUUQTRJJUBDPNMPWFFJUFNTBBBCF w

    IUUQTHJUIVCDPNEBOHFSTXJGU w IUUQTHJUIVCDPN[FOXBSF'J[[#V[[CMPCNBTUFSTIFMMTI w IUUQTNFEJVNDPNTXMIIPXUPTPMWF fi [[CV[[CGCGEE w IUUQTTUBDLPWFS fl PXDPNRVFTUJPOTNFBTVSFUIF TIFMMTDSJQUFYFDVUJPOUJNFJONJMMJTFDPOETPONBDPT