2015-02-23_RoboKidSize

背景:完成寒假任务



我的译文:

2、使用情况

数据结构表示和网络协议是这个库的两个最合适和平常的用处。从数据结构(C结构【struct】,C++类【class】或者F95用户定义的类型【user-defined type】)到字符串表达式[s-expression]是一种琐碎的步骤,以下是一些容易表示成字符串表达式[s-expression]的数据结构:

·树【trees】

·任意的有向图或者无向图【arbitrary directed or un-directed graphs】

·表【lists】

·字典或者哈希表【dictionaries, or hash-tables】

经常会有人需要一种方法存储或者修复结构到/从磁盘【save and restore structures to and from disk】,或者通过网络在两个应用间传输数据结构【or transmit a data structure over a network between two applications】。这自然导致网络协议上会有结构化地非平凡的数据来回通过【This naturally leads to network protocols where structurally non-trivial data is passed back and forth.】。字符串表达式[s-expression]使得数据能够以一种模拟原始数据结构的形式被内在地存储,并且以一种高效地解析或未解析的形式被传输。进一步,该库扩展了基本的字符串表达式[s-expression]使得内联二进制数据成为可能,去除了在发送之前要编码二进制数据(例如图像[image])的需要。这种二进制payload【真不知道payload该如何翻译】很容易被压缩成字符串表达式[s-expression]的形式,不需要安排成ASCII或者其他非二进制形式【without marshalling to ASCII or other non-binary formats】。

再进一步,以字符串表达式[s-expression]的形式在电线上传送数据结构在结构形式上不容易导致不同【data structures sent over the wire as s-expression are not prone to differences in architecture.】。不像系统发送纯二进制并且基于结构在语言和平台上连续展开的假设,这个字符串表达式[s-expression]是可移植,带有最小的内部整理自检以成为便携的表达式【Unlike systems that send pure binary and are based on the assumpution that structures are laid out consistently between languages and platforms, the s-expression is portable with minimal overhead to achieve this portable representation.这段翻译简直了,不忍直视】。在字符串表达式[s-expression]字节效率和原始的二进制之间有不可避免的权衡,但是不像其他的表示法(例如XML),它是最小的【There is an inevitable trade-off in byte efficiency with s-expression versus raw-binary, but unlike other representations (such as XML) it is minimal.这句话翻译得也是醉了】。解析也比XML或者其他‘文档结构语言’要更简单。也要注意对于内联二进制,至少就字节排序而言,可移植性是无效的【Also note that portability goes out the window with inlined binary, at least in terms of byte ordering.也翻不好】。

用了这个库并且让人能用到的示例包括:

·教高中几何学的工具(examples/simple_interp.c)

·LISP或者Scheme子集的解释器【Interpreters for subsets of LISP or Scheme】

·神经网络状态存储和获取

·仿真几何建立细胞自动机【Simulation geometry setup for cellular automata】

·仿真要用的“输入卡”参数【"Input deck" parameter files for simulations】

·集群监控所用的线路协议(Supermon)【Wire protocol for cluster monitoring (Supermon)】

·从源头到处理器传输图像信息的线路协议【Wire protocol for transmitting image data from source to processor】

传送你的应用软件时请别觉得有束缚!【Feel free to send your applications along to include here!】



我的译文:

3、实现细节

一个字符串表达式[s-expression]是由一个要么是原子[atom]要么是字符串表达式[s-expression]的元素所组成的表达式。举个例子,以下是包括两个元素的字符串表达式[s-expression]:

(a b)

(a (b c))

((a b) (c d))

(() ())

第一种情形,字符串表达式[s-expression]包括两个原子,字符串“a”和“b”。第二个例子包括一个原子和另外的字符串表达式[s-expression](包括两个原子[atom])。第三个例子由两个其他的字符串表达式[s-expression]组成。最后一个包括两个空字符串表达式[s-expression]。对于这些表达式的一种可能的表示法是嵌套的列表,列表中一个单独的元素捕捉在结构中:

struct elt{
<span style="white-space:pre">	</span>int type;
<span style="white-space:pre">	</span>char *val;
<span style="white-space:pre">	</span>struct elt *list;
<span style="white-space:pre">	</span>struct elt *next;
}
因为一个元素可以是一个列表[list]或者一个原子[atom],元素结构有一个type指示,它可以是LIST或者VALUE。如果type指示是LIST,那么结构成员“list”将成为

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值