惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Visual Studio Blog
I
InfoQ
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
D
Docker
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
量子位
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
J
Java Code Geeks
T
Tailwind CSS Blog
S
Securelist
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
雷峰网
雷峰网
D
Darknet – Hacking Tools, Hacker News & Cyber Security
小众软件
小众软件
Cloudbric
Cloudbric
N
News and Events Feed by Topic
L
LangChain Blog
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
L
LINUX DO - 热门话题
T
The Blog of Author Tim Ferriss
AWS News Blog
AWS News Blog
爱范儿
爱范儿
博客园 - 聂微东
Project Zero
Project Zero
V
Vulnerabilities – Threatpost
PCI Perspectives
PCI Perspectives
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - Franky
Y
Y Combinator Blog
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
AI
AI
The Last Watchdog
The Last Watchdog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CXSECURITY Database RSS Feed - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
美团技术团队
Google Online Security Blog
Google Online Security Blog
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
T
Tor Project blog

夜行人

回家路上 第一期的直播演示项目 震动检测器 正能量 在线参观CodeLab Neverland 发布 CodeLab Adapter 3.3.1 DynamicTable 之 纸糊方向盘 CodeLab DynamicTable: 一个可实施的技术方案 CodeLab Insight 发布 Alpha 版 情人节 Home Assistant 周报 && IoT 周报 (02) Joplin: 关注隐私的 Evernote 开源替代软件 浏览器的未来与 Web 传感器 Home Assistant 周报 && IoT 周报 (01) 百宝箱(01) 论自由 介绍 WebThings Home Assistant 周报 && iot 周报 (00) 百宝箱(00) 毛姆读书心得 传世之作 周末徒步 CodeLab Adapter ❤️ Jupyter/Python 航班 躲雨 夏令营途中 [译]思想--作为一种技术 The future of coding 美国之行 三门问题的程序模拟 从Python转向Pharo https://blog.just4fun.site/post/iot/iot-open-source-projects/ Python异步编程笔记 https://blog.just4fun.site/post/iot/iot-open-source-hardware-community/ 万物积木化开发者社区 CodeLab ❤️ Blender Scratch3技术分析之云变量 API(第7篇) [译]对管道(Pipes)的偏爱 [译]提出正确的问题比得到正确答案更重要 蓝牙设备与Scratch3.0 创建你的第一个Scratch3.0 Extension Scratch3技术分析之项目内部数据(第6篇) Scratch3技术分析之社区 API(第5篇) Scratch3技术分析之User API(第4篇) Scratch3技术分析之项目主页API(第3篇) Scratch3技术分析之静态资源API(第2篇) Scratch3.0、micro:bit与Windows7 https://blog.just4fun.site/post/iot/zerynth-vs-micropython/ 核聚变、方所与半宅空间 可视化编程为何是个糟糕的主意 codelab.club周末聚会 关于codelab.club '下一件大事'是一个房间 Hungry Robot - Eat everything 编程作为一种思考方式 今日简史 史蒂夫·乔布斯传 罗素自选文集 https://blog.just4fun.site/post/edx/tianjin-scratch-ai/ https://blog.just4fun.site/post/edx/richie-cms-openedx/ 徒步武功山 WebUSB与micro:bit 积木化编程与3D场景 夜宿武功山顶 scratch3-adapter接入优必选Alpha系列机器人 https://blog.just4fun.site/post/edx/video-migration-note/ scratch3-adapter重构笔记 https://blog.just4fun.site/post/edx/edx-community-members/ 两种硬件编程风格的比较 使用micro:bit自制PPT翻页笔 柏拉图对话集 scratch3.0 + micro:bit 七月电影放映计划 非营利组织的管理 Screenly--用树莓派让任何屏幕变为可编程的数字标牌 以最佳实践开始你的Django项目 micro:bit与事件驱动 为Scratch3.0设计的插件系统(上篇) OCR应用一例 近两年读过的一些好书 blockly开发之使用python驱动浏览器中的turtle(2) 牛顿新传 文学理论入门 逻辑的引擎 人生的意义 blockly开发之生成并运行js代码(1) blockly开发之hello world(0) micro:bit使用笔记 神器之Termux https://blog.just4fun.site/post/iot/micropython-notes/ Cozmo what is this Scratch的前世今生 下段旅程 我行在远方 爆裂 途中杂记 https://blog.just4fun.site/post/edx/open-edx-startup/ cozmo系列之入门 - 有性格且可编程的机器人 PaperWeekly开发笔记 创业二三事
Squeak 备忘
种瓜 · 2020-11-18 · via 夜行人

文章目录

日常备忘。

由于 Pharo 派生自 Squeak,所以很多资源是可以共用的

一些材料

语法备忘

Terse Guide to Squeak

Array(list)

将 list 视为不可变的结构(历史不可变),每次都生成新的.

发挥 LISP 精神,灵活操控 list。

只使用少量操作符:

  • atom
  • eq (x=y)
  • car ([:x |x at: 1.])
  • cdr ([:x |x copyFrom: 2 to: x size.])
  • cons ([:x :y|Array with: x with: y])
  • cond (ifTrue:)
1
2
3
4
5
6
car := [:x |x at: 1.].
cdr := [:x |x copyFrom: 2 to: x size.].
cons:= [:x :y|Array with: x with: y].
car value: #(1 2 3 ).
cdr value: #(1 2 3 ).
cons value: #(1 2 3 ) value: 1.

Smalltalk 源码不是S表达式,尽可能将 list 用作 S表达式, 灵活使用 block, 诸如: #([:x |x at:1.], 1 2 3)

1
2
y := {[:x |x at:1.] . 1 . 2 . 3}.
(car value: y) value: (cdr value: y). "1"

由于 Smalltalk 和LISP 一样(Alan Kay是LISP忠实粉丝)是一门关注late binding的语言,所以 list 中可以携带各种东西!

1
2
3
"receiver perform: message."
y := {'factorial' asSymbol . 5 . 6 . 7}.
(car value: (cdr value: y)) perform: (car value: y). "120 (5x4x3x2x1)"

create

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x := #(4 3 2 1). 

"Array 长度固定"
x := Array with: 5 with: 4 with: 3 with: 2.                 "create array with up to 4 elements"

x := Array new: 4.                                          "allocate an array with specified size"
x                                                           "set array elements"
   at: 1 put: 5;
   at: 2 put: 4;
   at: 3 put: 3;
   at: 4 put: 2.

a := 'hi'
x := {a . 1 . 2} "a 将被解析。 #(a 1 2)->a是symbol"

query && utils

1
2
3
4
5
x isEmpty.
x size.
x includes: 3.
x select: [:a | a > 2].
x do: [:a | Transcript show: a printString; cr].            "iterate over the array"

Dictionaries

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x := Dictionary new.
x at: #e put: 3.
x at: 'key1' put: 3.
x includesKey: #a.
x keys.
x values.
x do: [:a | Transcript show: a printString; cr]        "iterate over the values collection"
x keysDo: [:a | Transcript show: a printString; cr].   "iterate over the keys collection"
x keysAndValuesDo: [:aKey :aValue | Transcript         "iterate over keys and values"
   show: aKey printString; space;
   show: aValue printString; cr].
x select: [:a | a > 2].       "return collection(dict) of elements that(value) pass test"

Smalltalk globals keys

环境介绍(视频)

Squeak from the very start

常用

Morphic

Morphic

late binding

在持续积累 late binding 相关技能

Dynamic Message Calling/Compiling

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"unary message"
receiver := 5.
message := 'factorial' asSymbol.
result := receiver perform: message.
result := Compiler evaluate: ((receiver storeString), ' ', message).
result := (Message new setSelector: message arguments: #()) sentTo: receiver.

"binary message"
receiver := 1.
message := '+' asSymbol.
argument := 2.
result := receiver perform: message withArguments: (Array with: argument).
result := Compiler evaluate: ((receiver storeString), ' ', message, ' ', (argument storeString)).
result := (Message new setSelector: message arguments: (Array with: argument)) sentTo: receiver.

"keyword messages"
receiver := 12.
keyword1 := 'between:' asSymbol.
keyword2 := 'and:' asSymbol.
argument1 := 10.
argument2 := 20.
result := receiver
   perform: (keyword1, keyword2) asSymbol
   withArguments: (Array with: argument1 with: argument2).
result := Compiler evaluate:
   ((receiver storeString), ' ', keyword1, (argument1 storeString) , ' ', keyword2, (argument2 storeString)).
result := (Message new
      setSelector: (keyword1, keyword2) asSymbol
      arguments: (Array with: argument1 with: argument2))
   sentTo: receiver.

连接

与外部系统通信

OSC

Adatper Squeak

在Squeak中, 下载 OSC : OSC-SimonHolland, 之后拖到 Squeak 桌面,加载使用即可。

1
2
3
4
5
(OSCMessage for: {'/eim/osc' . 1}) sendTo: #[127 0 0 1] port: 12361. 

(OSCMessage for: {'/eim/osc' . 0}) sendTo: #[127 0 0 1] port: 12361.

(OSCMessage for: {'/eim/osc' . -1}) sendTo: #[127 0 0 1] port: 12361. 

Scratch Client

Adapter Etoys

解析工具

参考