Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rust ownership from legal perspective
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
homuler
May 30, 2016
Programming
110
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rust ownership from legal perspective
Rustのownershipは所有権ではなかった件
homuler
May 30, 2016
More Decks by homuler
See All by homuler
JavaScript Course at Arzano Royal Institute of Magic
homuler
0
89
Style Transfer Overview in 5 minutes
homuler
0
100
Other Decks in Programming
See All in Programming
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.5k
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
280
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
4
420
iOSDCのペンライトを自動制御したい!
akkeylab
0
280
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
200
iOSDC2026登壇資料.pdf
riofujimon
0
200
mrbgem 三角測量 開発
ogom
0
150
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2k
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
250
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
510
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
220
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
170
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1369
210k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
How to build a perfect <img>
jonoalderson
1
6k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
380
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
420
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
530
The World Runs on Bad Software
bkeepers
PRO
72
12k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
240
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
Git: the NoSQL Database
bkeepers
PRO
432
67k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
440
Transcript
Rustのownershipは 所有権のこと だと思った?
1. Rust • Mozillaが開発中のプログラミング言語 – C++が対抗馬 • GCがないが、メモリ安全性を担保 • Firefox(Gecko)の一部実装に使われている
– https://wiki.mozilla.org/Oxidation
2. Memory safe • Ownership – 所有権にたとえられる • Borrowing –
(使用/消費)貸借にたとえられる • Lifetimes
2. Memory safe • Ownership – 所有権? • Borrowing –
(使用/消費)貸借? • Lifetimes – 「人が深淵を覗く時、深淵もまた人を覗いている」
3. OwnershipとBorrowing • 変数宣言に関するルール • ある値に対するownershipを持つ変数(x)がある • 別の変数が同じ値を使う際は、(xの)ownershipをborrowする – この表現がかなりミソ
• 常にどちらかの状態を維持する – 値を参照するだけの変数(Immutable borrowing)が複数 – 値を変更可能な変数(Mutable borrowing)がただ一つ • 違反するとコンパイルエラー • 実行時のオーバーヘッドはない – コンパイル時チェックのみ
本当に貸借? borrowingのサンプル // コンパイルエラーになる fn main() { let xs =
vec![1, 2, 3]; for x in xs { println!("{}", x); } println!("{:?}", xs); }
本当に貸借? borrowingのサンプル // コンパイルエラーになる fn main() { let xs =
vec![1, 2, 3]; for x in xs { // move(ownershipが移る) println!("{}", x); } println!("{:?}", xs); // Error }
本当に貸借? borrowingのサンプル fn main() { let xs = vec![1, 2,
3]; for x in &xs { // borrowing(ownershipはそのまま) println!("{}", x); } println!("{:?}", xs); }
本当に貸借? borrowingのサンプル fn main() { let xs = vec![1, 2,
3]; for x in &xs { // borrowing(ownershipはそのまま) println!("{}", x); } println!("{:?}", xs); } 見せてもらっただけ、だけど一応借りてそう
本当に所有権? Borrowingのサンプル(mutable) // 配列を空にする fn emptify(xs: &Vec<usize>) { while
xs.len() > 0 { xs.pop(); // Error(Immutable!) } } fn main() { let xs = vec![1, 2, 3]; emptify(&xs); }
本当に所有権? Borrowingのサンプル(mutable) // 配列を空にする fn emptify(xs: &mut Vec<usize>) { while
xs.len() > 0 { xs.pop(); } } fn main() { let mut xs = vec![1, 2, 3]; emptify(&mut xs); }
本当に所有権? Borrowingのサンプル(mutable) // 配列を空にする fn emptify(xs: &mut Vec<usize>) {
while xs.len() > 0 { xs.pop(); } } fn main() { let mut xs = vec![1, 2, 3]; emptify(&mut xs); } 中身全部抜いてますけど・・
5. Borrowing再考 • Immutableのborrowing – 値は見るだけ – 法律行為(契約)でない可能性も • 渋谷駅にある「明日の神話」みたいな
• 警備員(コンパイラ)に止められるだけ • 入場規制はあるので、微妙なところ – 揚げ足を取るのはやめます
5. Borrowing再考 • Mutableのborrowing – 「借主」はやりたい放題 – もはや所有権を一度譲渡しているように見える – いずれ返されるので、「貸主」は何か
(ownership)を保持しているはず
• そういえば、ローマ法にあった – 「権原」 – 所有権の上位概念で、所有権の根拠になるもの – 日本では立法者が理解できなかったので、権原≒所有権 • 所有権だって条件(期限)付き譲渡できる、はず
– (日本法だと苦しい) – cf. 忘恩行為による贈与取り消し、終期付き譲渡など (東京地裁昭和50年12月25日判決) – 日本法ではなかった • 所有権(ownership)を借りる(borrow)という表現自体がおかしい • 「何か」 = ownership ≒ 権原 ≠ 所有権 Q.E.D 6. Ownership再考
まとめ • 譬え話にマジレスしてはいけない • でも、Rustはいいものです