我将如何重新定义内置函数,同时以不同的名称保持对旧函数的引用?
即与SBCL
(unlock-package 'common-lisp)
(defun old+ (a b) ??????
(defun + (a b) (old+ a b))
Run Code Online (Sandbox Code Playgroud)
我正在将代码移植到没有float数据类型的LISP实现.所以我想重新定义数学运算以使用固定整数数学.
我想我可以通过搜索和替换来解决这个问题:)
有人可以告诉我为什么这个代码段失败并出现以下错误?utf8::downgrade()在打电话之前我也尝试
过from_to()没有成功.使用Perl 5.14.2.
有任何想法吗??
码:
use Encode qw(from_to);
use HTML::Entities;
$s = "มหัศ";
$foo = decode_entities($s);
print "is foo UTF8? ", utf8::is_utf8($foo), "\n";
from_to($foo, 'UTF-8', 'UTF-16');
Run Code Online (Sandbox Code Playgroud)
输出:
is foo UTF8? 1
Cannot decode string with wide characters at /usr/lib/perl/5.14/Encode.pm line 194.
Run Code Online (Sandbox Code Playgroud) 为什么这段代码溢出了CMUCL堆?即使我给它400MB内存(setq extensions:*bytes-consed-between-gcs* 400000000)CMUCL仍然会扼杀它.
; [GC threshold exceeded with 12,012,544 bytes in use. Commencing GC.]
; [GC completed with 188,064 bytes retained and 11,824,480 bytes freed.]
; [GC will next occur when at least 400,188,064 bytes are in use.]
; [GC threshold exceeded with 400,202,280 bytes in use. Commencing GC.]
; [GC completed with 207,120 bytes retained and 399,995,160 bytes freed.]
; [GC will next occur when at least 400,207,120 bytes are in use.]
Run Code Online (Sandbox Code Playgroud)
这段代码可以运行CCL和SBCL,但我还没看过他们的内存使用情况.
这是CMUCL中的一个错误吗?我相信所有这些功能都是尾递归的.
(defun sqrt-iter (guess …Run Code Online (Sandbox Code Playgroud) 我有如下编译问题.头文件abc.h包含在abc.c.
在头文件中,我有这个
extern char **foo;
Run Code Online (Sandbox Code Playgroud)
在源文件中,我有这个
char *foo[] = { ".mp3", ".mp4" };
Run Code Online (Sandbox Code Playgroud)
然而我从GCC得到了编译错误:
abc.c:23:7: error: conflicting types for ‘foo’
In file included from abc.c:18:0:
abc.h:64:15: note: previous declaration of ‘foo’ was here
Run Code Online (Sandbox Code Playgroud)
为什么我会收到此错误?