Forwarded from Deleted Account
今天又有人问我怎么不再写技术文章了,俺说到:... 技术文章容易沦为不负责任(因为时间推移,作者见解可能改变,文章内容本身可能过时,需要更新,比较费力);
所以有空的时候,博客还是要再清理一番,以后有机会的话,可以转为「感慨博客」,发发各种感慨,多好(drakeet 从初中到现在一直在 QQ 空间发布各种黑历史感慨文章,至今有几百篇了)。不过因为博客网站是完全公开的,还没考虑清楚(其实问题也不大,完全公开也好),导致此计划一直没有施行。
所以有空的时候,博客还是要再清理一番,以后有机会的话,可以转为「感慨博客」,发发各种感慨,多好(drakeet 从初中到现在一直在 QQ 空间发布各种黑历史感慨文章,至今有几百篇了)。不过因为博客网站是完全公开的,还没考虑清楚(其实问题也不大,完全公开也好),导致此计划一直没有施行。
duangsuse::Echo
等 Lime 做完 Ruby、Java、JavaScript 的展开器、写完一个能用的std和oop插件后我就回去做 GeekApk
昨天考虑到方便访问展开规则的缘故把 Hash 加入原生类型里了
现在有
和
(然后Hash既然有了就干脆也实现 OOP 吧, libstd 也使用 oop\
现在有
Macro Hash List String Symbol Bool Number Nil 八种原生类型 (预备以后的 Native 解释器实现)和
→ # ⇒ : :' ' " ~ ⇢ ↻ ↷ ? $ :: ::= ⤓ 🖬 几个内部实现的 以及 .(然后Hash既然有了就干脆也实现 OOP 吧, libstd 也使用 oop\
#project Lime 今天下午又有一些变更,总的来说:
1. OOP 支持, Ruby 由于足够灵活方便所以(Ruby 版本)没有内建,而是包 std/oop 使用插件(当然也有 Lime)实现的
具体工作方法可以等 wiki
例子:
2. 详细了一下项目方案...
包括 CI, Spec, Wiki, 文档和主页之类
3. 内部的几个 Lime dispatch 绑定改名,详细文件和 FCL 结构,一点开发计划...
4. 语法修改支持更多 Symbol 操作, 详细化了 Lime 库\插件支持
1. OOP 支持, Ruby 由于足够灵活方便所以(Ruby 版本)没有内建,而是包 std/oop 使用插件(当然也有 Lime)实现的
具体工作方法可以等 wiki
例子:
(10.times (do (th)
(puts "Hello, world! #:#{th}")))
(-> File std::File)
(-> a_file (File::open 'a.txt :r))
(puts (a_file.read))
FooHash::FooKey::NestingClass::new.call_a_func
(class A
(super std::Object)
(def self.classmethod (puts 'a))
(def a_method 1))
(class B
(super A)
(include FooHash::FooMod)
(initialize)
(def a self::a)
(def a= (value)
(self::a= value)))
(r :(B::new).a) ;=> nil
(-> b_obj (B::new))
(b_obj.a= 1)
(b_obj.a) ;=> 1
(b_obj.a_method) ;=> 1
(b_obj.class) ;=> "B"
(b_obj.class.superclass) ;=> "A"
P.S: 最原始的其实是这样
(-> B (=>
name: "B"
class: "std::Class"
superclass: "A"
;......
(-> A (=>
name: "A"
class: "std::Class"
superclass: "std::Object"
#a_method: (# 1)
classmethod: (# (puts 'a))))
2. 详细了一下项目方案...
包括 CI, Spec, Wiki, 文档和主页之类
3. 内部的几个 Lime dispatch 绑定改名,详细文件和 FCL 结构,一点开发计划...
4. 语法修改支持更多 Symbol 操作, 详细化了 Lime 库\插件支持
duangsuse::Echo
#project Lime 今天下午又有一些变更,总的来说: 1. OOP 支持, Ruby 由于足够灵活方便所以(Ruby 版本)没有内建,而是包 std/oop 使用插件(当然也有 Lime)实现的 具体工作方法可以等 wiki 例子: (10.times (do (th) (puts "Hello, world! #:#{th}"))) (-> File std::File) (-> a_file (File::open 'a.txt :r)) (puts (a_file.read)) F…
展开器使用了更加灵活的方式:
现在只有
现在只有
(. builtin_expanderid *args) 是亲定的了,其他前置展开器都变成普通的 Macro, 类似这样:module Lime
module Builtins
symbol '^#', 'Create a macro object'
def macro_ctor(args_or_body, body = nil)
body.nil? ? Lime::Macro.new([], args_or_body) : Lime::Macro.new(args_or_body, body)
end
make_symtbl
end
end
duangsuse::Echo
展开器使用了更加灵活的方式: 现在只有 (. builtin_expanderid *args) 是亲定的了,其他前置展开器都变成普通的 Macro, 类似这样: module Lime module Builtins symbol '^#', 'Create a macro object' def macro_ctor(args_or_body, body = nil) body.nil? ? Lime::Macro.new([], args_or_body) : Lim…
# 宏 可以这么使用:(# 1)
(# (puts '我爱北京包子铺))
(# () ())
(# (arg) (puts arg))
另外又加了个
(tostring) 宏
duangsuse::Echo
#project Lime 今天下午又有一些变更,总的来说: 1. OOP 支持, Ruby 由于足够灵活方便所以(Ruby 版本)没有内建,而是包 std/oop 使用插件(当然也有 Lime)实现的 具体工作方法可以等 wiki 例子: (10.times (do (th) (puts "Hello, world! #:#{th}"))) (-> File std::File) (-> a_file (File::open 'a.txt :r)) (puts (a_file.read)) F…
This media is not supported in your browser
VIEW IN TELEGRAM
duangsuse::Echo
#project Lime 今天下午又有一些变更,总的来说: 1. OOP 支持, Ruby 由于足够灵活方便所以(Ruby 版本)没有内建,而是包 std/oop 使用插件(当然也有 Lime)实现的 具体工作方法可以等 wiki 例子: (10.times (do (th) (puts "Hello, world! #:#{th}"))) (-> File std::File) (-> a_file (File::open 'a.txt :r)) (puts (a_file.read)) F…
Lime 好用之处在使用 Java 版的解释器的时候....
给了 Java 更好的动态性、小体积和 Ruby-like syntax 🌑
等着拿到 Android 上用而已
给了 Java 更好的动态性、小体积和 Ruby-like syntax 🌑
等着拿到 Android 上用而已
duangsuse::Echo
展开器使用了更加灵活的方式: 现在只有 (. builtin_expanderid *args) 是亲定的了,其他前置展开器都变成普通的 Macro, 类似这样: module Lime module Builtins symbol '^#', 'Create a macro object' def macro_ctor(args_or_body, body = nil) body.nil? ? Lime::Macro.new([], args_or_body) : Lim…
Macro 也是支持可选参数和参数列表的(
(# (a b c=1 d=#t *rest) (rest))
duangsuse::Echo
Macro 也是支持可选参数和参数列表的( (# (a b c=1 d=#t *rest) (rest))
不过现在没想好填充真实方法参数列表的算法(
等等我就把理论说完吧(
Lime 原生类型
BNF (或许是伪造的,反正也只是参考罢了
(或许应该支持注释和 debug info 和跳过空白,还有一点sugar 大概有
Lime 原生类型
Type | (tostring T) | textual repr.
Macro | lmacro | (# arg_tbl body) (# body) ; by built-in macro ^#
Hash | lhash | (=> key1: value1 key2: value2) ; by built-in macro ^=>
List | llist | () (()) (()())
String | lstring | 'string "string"
Symbol | lsymbol | :a :"it's a symbol" :(car list) :'ssss'
Bool | lboolean | #t #f
Number| lnumeric | 0x21212i32 0b3232 43 0.4 768f32
Nil | lnull | ⚪️ () ; expanded to nil
BNF (或许是伪造的,反正也只是参考罢了
(或许应该支持注释和 debug info 和跳过空白,还有一点sugar 大概有
ending -> ' '|')'|'\t'|'\n'
number -> (0x|0b|0o) [0-9]* (u8|i8|u16|i16|u32|i32|u64|i64|u128|i128|f32|f64) ending
stringa -> '\'' string_data ending
stringb -> '"' string_data '"'
string -> stringa|stringb
nil -> ⚪️
bool -> '#' t|f
symbol -> ':' string|list ; 其实有一些特殊逻辑...
list -> '(' obj* ')'
obj -> list|number|string|nil|bool|symbol|
内部定义的宏:
内部定义环境:
-> define
-? defined?
-x undef
<- read
. send
=> hash
# macro
: as_symbol
:< back_symbol
:' as_sexp
' as_array
" as_string_array
~ sequence
~~ must_sequence
` loop
`` must_loop
? cond
% typeof
:: index
::= indexeq
ext< loadext
ext> unloadext
require require
eval eval
dup dup
^ car
$ cdr
λ lambda ;就是让 macro 内联上当前(全局,Lime里没作用域的概念)环境变量而已
@ puts
@> warn
@< input
#< macro_args
#> macro_body
[] index_dynamic
[]= indexeq_dynamic
[]? haskey
[]- length
[]* allkey
"- strlen
"< gsub
"> match
"? is_include
": locate
+ add
++ inc
-- dec
- sub
* mul
/ div
** pwr
% mod
> lt
< bg
>= le
<= bg
<=> cmp
<< shl
>> shr
& and
| or
! not
^ xor
eh errorhandler
!! raise
r valueof(just_return)
p print
-># tomacro
->> tohash
->[] tolist
->" tostring
->: tosymbol
->B toboolean
->N tonumber
->() tonil
内部定义环境:
LVERSION lime version
LENGINE lime engine
LENV lime environment
LLIBPATH lime lib path
ENV os environ
ARGV cmdline argument
LFILE expanding file
$* argv
$_ file
$__ file parent dir
$: loaded files
$! exception
$@ exception postion
$~ match
$$ pid
$? child status
$. last readline number
$= ignorecase
duangsuse::Echo
内部定义的宏: -> define -? defined? -x undef <- read . send => hash # macro : as_symbol :< back_symbol :' as_sexp ' as_array " as_string_array ~ sequence ~~ must_sequence ` loop `` must_loop ? cond % typeof :: index ::= indexeq ext< loadext ext> unloadext require…
This media is not supported in your browser
VIEW IN TELEGRAM