Forwarded from 任桑 今天开始做魔王
所以抄个别的语言的代码套在py上,我是否可以理解为你既不熟悉scheme也不熟悉py呢,不然你干嘛要抄
Forwarded from dnaugsuz
只是习惯了,好比我之前写过 Haskell,所以喜欢用
for x in xs: 一些,谁能因此断言 for 一定是 Haskell way (forM_) 或者 x/xs 一定是 Python way?Forwarded from dnaugsuz
其实我上面喷的单纯是那个必须 explicit 的 self 参数,在 Rust 这样“多范式”的语言里往往才是这样(事实上,Rust 是有 impl 的,不需要显式写 self 参数)
以及一个
给人感觉设计上不够坚定,把
以及一个
str.join 的小问题——别的语言都是 iter.join,Python 给搞个 str.join,还是“面向对象”语言给人感觉设计上不够坚定,把
re module 不和 built-in str 结合在一起可以认为是“工程”的,可 a join xs 这种命名方法完全是过分模拟自然语言语序,虽然 Python 是很早就诞生的“脚本语言”所以有些问题很正常,我觉得作者的设计水平还是感觉一般Forwarded from dnaugsuz
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Forwarded from dnaugsuz
看来 Python 的 core devs 还是一群文艺青年,我还以为导入这个模块可以提供
this 字面名呢Forwarded from dnaugsuz
Complex is better than complicated.
是啊,可是 self 哪里比 implicit this (实际上有点像作用域策略) 更 *不* complicated 的了?
是啊,可是 self 哪里比 implicit this (实际上有点像作用域策略) 更 *不* complicated 的了?
上等讨论是交流观点,中等讨论是谈论事件,低等讨论是评判个人。
——浅谈价值表达
——浅谈价值表达
浅谈价值表达
浅谈价值表达 | 小胡子哥的个人网站
还记得刚踏入职场时,最大的困惑是不清楚未来的成长路径是怎样的,在职场上,我的未来是什么?未来的路该怎么走?业界的那些大牛,到底有多牛?我离他们有多远?对此完全没有概念。
duangsuse::Echo
上等讨论是交流观点,中等讨论是谈论事件,低等讨论是评判个人。 ——浅谈价值表达
第三次,我居然一句话没说(叮~counter+1),麻木了吗?还是我本来就不应该考虑那些事情?
我……真的不能写应用? 🤔
我……真的不能写应用? 🤔
刚才我看到了 https://azul.rs/ 的 button counter 示例程序,默写下? #code
第二次
//use ...
struct Counter {
count: i32
}
impl Layout for Counter {
fn layout(self: Counter, _info: &LayoutInfo) -> Dom {
let label = Label::new(format!("{}", self.count)).dom();
let button = Button::new("+1")
.clicked(Callback(onIncClicked));
Dom::div()
.add(label).add(button)
}
fun onIncClicked(self: Counter) -> ScreenUpdate {
self.count += 1
Redraw
}
} 第二次
extern create azul;
use azul::{ prelude::*, label::Label, button::Button }
struct AppState {
counter: usize
}
impl Layout for AppState {
fun layout(&self, _info: LayoutInfo<Self>) -> Dom<Self> {
let label = Label::new(format!("{}", self.counter));
let btn_inc = Button::new("+1").handle("click", Callback(onIncClicked));
Dom::new().with_child(label).with_child(btn_inc);
}
fun onIncClicked(&mut self) -> ScreenUpdate {
self.counter += 1
Redraw
}
}azul.rs
Azul GUI Framework
Cross-platform MIT-licensed desktop GUI framework for C and Rust using the Mozilla WebRender rendering engine
extern create azul;
use azul::{ prelude::*, widget::{ label::Label, button::Button } };
struct DataModel {
counter: usize
}
impl Layout for DataModel {
fn layout(&self, _info: LayoutInfo<DataModel>): Dom<DataModel> {
let label = Label::new(format!("{}", self.counter));
let btn_inc = Button::with_label("+1").add_action(On::MouseUp, Callback(onIncClicked));
Dom::div().with_child(label).with_child(btn_inc)
}
fn onIncClicked(info: EventInfo<DataModel>) -> ScreenUpdate {
info.state.data.counter += 1
Redraw
}
}
duangsuse::Echo
extern create azul; use azul::{ prelude::*, widget::{ label::Label, button::Button } }; struct DataModel { counter: usize } impl Layout for DataModel { fn layout(&self, _info: LayoutInfo<DataModel>): Dom<DataModel> { let label = Label::new(format!("{}"…
extern crate azul;
use azul::{prelude::*, widgets::{label::Label, button::Button}};
struct DataModel {
counter: usize,
}
impl Layout for DataModel {
fn layout(&self, _info: LayoutInfo<Self>) -> Dom<Self> {
let label = Label::new(format!("{}", self.counter)).dom();
let button = Button::with_label("Update counter").dom()
.with_callback(On::MouseUp, Callback(update_counter));
Dom::div()
.with_child(label)
.with_child(button)
}
}
fn update_counter(event: CallbackInfo<DataModel>) -> UpdateScreen {
event.state.data.counter += 1;
Redraw
}
fn main() {
let mut app = App::new(DataModel { counter: 0 }, AppConfig::default()).unwrap();
let window = app.create_window(WindowCreateOptions::default(), css::native()).unwrap();
app.run(window).unwrap();
} 这是真实代码
fun main() {
let mut app = App::create(DataModel { counter = 0 }).unwrap();
let win_main = Window::create(WindowOptions::default(), css:native).unwrap();
app.run(win_main).unwrap()
} fun main() {
let mut app = App::new(DataModel { counter = 0 }, AppOptions::default()).unwrap();
let win_main = app.create_window(WindowOptions::default(), css::native).unwrap();
app.run(win_main).unwrap();
}
unwrap() 几乎写到手软,记得当初信 Rust 教的时候,对这个名词相当困扰,不知道它是 Option<T> 上的一个操作……Forwarded from dnaugsuz
啊,很老很老的 Intel x86 架构手册,一般只有编译器后端的工程师才会看的那种
Forwarded from dnaugsuz
对我来说,如果一个人有学姐的名号,就是要向请教的晚辈主动提供些信息的
现在不少的大佬,带着权威的性格,却一个字也不会给提问的人透露
现在不少的大佬,带着权威的性格,却一个字也不会给提问的人透露