--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛中的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com。
要查看更多选项,请访问https://groups.google.com/d/optout。
好大一个坑
from nexus 4
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
Guile & guile-scsh
Chaos <ch...@shlug.org>
CC BY
GNU Guile
GNU Ubiquitous Intelligent Language for Extensions
Usually Scheme R5RS, partially R6RS
Originally developed as a glue language
But with Strong Feature and actively developed
Scheme
Minimalism
Simple, clean and easy to implement.
R5RS has only 23 s-exps.
First Class Functions
(define (my-apply f x1 x2) (f x1 x2)) (my-apply + 1 2) ;; 3 (my-apply (lambda (x y) (+ x (* 2 y))) 1 2) ;; 5Shared namespace bewteen procedures and variables
Different with common-lisp
Lexical Scope
Unlike emacs lisp and ancient lisp machines, Scheme is lexicaly scoped.
(define (my-complex-construct x y) (let ((r x) (i y)) (lambda (m) (if (eq? m 'r) r i)))) (define c (my-complex-construct 1 3)) (c 'r) ;; 1 (c 'i) ;; 3
Macros and Hygienic Macros
easily to extend
(define-syntax let (syntax-rules () ((let ((var expr) ...) body ...) ((lambda (var ...) body ...) expr ...))))
* Codes from wikipedia
Proper tail recursion
Tail Call Optimization
(define (fact n) (define (iter n x) (cond ((= n 0) x) (#t (iter (- n 1) (* n x))))) (iter n 1) ) (fact 4) ;; 24 (fact 100000) ;; Output is intentially omitted
First Class Continuations
Contination is a snapshot of the current state of running process, call/cc will let process return to a saved snapshot.
From Wikipedia:
First-class continuations enable the programmer to create non-local control constructs such as iterators, coroutines, and backtracking.
call/cc
(let* ((yin ((lambda (cc) (display "@") cc) (call-with-current-continuation (lambda (c) c)))) (yang ((lambda (cc) (display "*") cc) (call-with-current-continuation (lambda (c) c))))) (yin yang))Delimited Continuations
More easier to use and control. (Full-continuation considered harmful)
Guile Features
- SLIB::
- POSIX::
- Web::
- SRFI Support::
- R6RS Support::
- Pattern Matching::
- Readline Support::
- Pretty Printing::
- File Tree Walk::
- Queues::
- Streams::
- Expect::
- sxml-match::
- Curried Definitions::
- Statprof::
- SXML::
Not only Scheme!
Guile compiler tower
Layered infrastucture , from high language to middle layer then virtual machine with JITs(in-development).
10x faster promised in 2.2 release
Emacs Lisp
elisp compiled using Guile.
And theres is someone in doing [http://www.emacswiki.org/emacs/GuileEmacs].
BrainF***
Python/Lua...
And More
Guile-XCB
[https://github.com/mwitmer/guile-xcb]
X11 protocal compiled using Guile!
Guile-WM
Window Manager! [https://github.com/mwitmer/guile-wm]
Things using Guile
From WikiPedia:
- GnuCash
- GNU Debugger (gdb) - since version 7.8
- GNU LilyPond
- GNU Make - since version 4.0
- GNU MDK
- GNU Robots
- GNU Serveez
- Guix - a functional package manager inspired/fork of NixOS
- GNU TeXmacs
- Liquid War 6
- mcron - a backwards compatible replacement for Vixie cron written in Guile
guile-scsh
In the beginning, there is only scsh
Scheme Shell, Unix Shell using s-exps and scheme language. [http://scsh.net/]
scsh ported to guile
reborn to guile-2.x
[https://gitorious.org/guile-scsh]
BSD-license.
scsh details
Run Process
scheme@(guile-user)> (run (ls)) COPYING docs examples INSTALL install.scm pkg-list.scm scsh temp.scm test test-suite TODO USAGE $2 = 0Pipe
scheme@(guile-user)> (run (| (ls) (grep COPY))) COPYING $1 = 0 scheme@(guile-user)>running process in background, with pipe
scheme@(guile-user)> (& (| (ls) (grep COP))) $4 = #{proc 3084} scheme@(guile-user)> COPYING
More Examples
quasi-quote
scheme@(guile-user)> (define ls '(ls --color=auto)) scheme@(guile-user)> (run ,ls) COPYING guile-scsh.scm scsh test USAGE $3 = 0input/output
scheme@(guile-user)> (run (wc -l ) (< /etc/issue)) 2 $2 = 0 scheme@(guile-user)> (run (cat ) (< /etc/issue)) Arch Linux \r (\l) $3 = 0 scheme@(guile-user)> (run (grep Arch ,@(glob /etc/*)) (> 2 /dev/null)) /etc/issue:Arch Linux \r (\l) ... /etc/os-release:PRETTY_NAME="Arch Linux" $4 = 512 scheme@(guile-user)>
and more
temp-files
scheme@(guile-user)> (call/temp-file (lambda () (run (ls ) (= 1 (current-output-port)))) (lambda (x) (run (,@ls -l ,x)))) -rw------- 1 chaos chaos 44 Mar 6 15:41 /tmp/5310.61038 $12 = 0globbing
scheme@(guile-user)> (run (ls ,@(glob /bin/l*))) /bin/l2ping /bin/ld.gold /bin/lex /bin/l2test /bin/ld_iscsi.so /bin/lexgrog /bin/labltk /bin/ldns-chaos /bin/lftp
TODO
- Full Terminal Support
- filename and command name completion
- awk/sed replacement
- rewrite fork?
...
你是说42么?
新东方规模大,二十万学子遍天下,学好厨师好处多,好处多的没法说,工作稳定收入高,终身就业有保障,有保障!
居然不是”学挖掘机技术哪里最强“结尾,有点不适应了。。
>
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛中的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com。
要查看更多选项,请访问https://groups.google.com/d/optout。