From 36c50e2f193a763d0f2e1275a66452b4665868eb Mon Sep 17 00:00:00 2001 From: Guilherme Affonso Date: Thu, 25 Apr 2019 22:37:40 +0900 Subject: [PATCH 1/3] Add :init to complex --- lisp/l/extnum.l | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/l/extnum.l b/lisp/l/extnum.l index 596579b15..a96f674ef 100644 --- a/lisp/l/extnum.l +++ b/lisp/l/extnum.l @@ -2,5 +2,10 @@ (:init (num denom) (setq numerator num denominator denom) - self) -) + self)) + +(defmethod complex + (:init (re im) + (setq real re + imaginary im) + self)) From 4746fbf3bf610cbaf18ee389d2ff38728ef71977 Mon Sep 17 00:00:00 2001 From: Guilherme Affonso Date: Thu, 25 Apr 2019 22:38:48 +0900 Subject: [PATCH 2/3] Reduce \classdesc header size --- doc/jlatex/jmanual.tex | 2 +- doc/latex/manual.tex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/jlatex/jmanual.tex b/doc/jlatex/jmanual.tex index bcafff1d9..c4b9f3cba 100644 --- a/doc/jlatex/jmanual.tex +++ b/doc/jlatex/jmanual.tex @@ -102,7 +102,7 @@ \newcommand{\classdesc}[4]{ %class, super slots description \vspace{2mm} \index{#1} -{\Large {\bf #1 }} \hfill [クラス] %super +{\large {\bf #1 }} \hfill [クラス] %super \begin{tabbing} \hspace{30mm} :super \hspace{5mm} \= {\bf #2} \\ \hspace{30mm} :slots \> #3 diff --git a/doc/latex/manual.tex b/doc/latex/manual.tex index c60923d46..f709cc18b 100644 --- a/doc/latex/manual.tex +++ b/doc/latex/manual.tex @@ -107,7 +107,7 @@ \newcommand{\classdesc}[4]{ %class, super slots description \vspace{2mm} \index{#1} -{\Large {\bf #1 }} \hfill [class] %super +{\large {\bf #1 }} \hfill [class] %super \begin{tabbing} \hspace{30mm} :super \hspace{5mm} \= {\bf #2} \\ \hspace{30mm} :slots \> #3 From 22157a012492628ffe42eb6f64140b7c61755cc0 Mon Sep 17 00:00:00 2001 From: Guilherme Affonso Date: Thu, 25 Apr 2019 22:40:51 +0900 Subject: [PATCH 3/3] Add ratio and complex number documentation --- doc/jlatex/jarith.tex | 17 +++++++++++++++++ doc/jlatex/jgenerals.tex | 1 + doc/jlatex/jintro.tex | 2 +- doc/latex/arith.tex | 17 +++++++++++++++++ doc/latex/intro.tex | 4 ++-- doc/latex/types.tex | 13 +++++++------ 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/doc/jlatex/jarith.tex b/doc/jlatex/jarith.tex index f3c999c78..e85c19de2 100644 --- a/doc/jlatex/jarith.tex +++ b/doc/jlatex/jarith.tex @@ -317,5 +317,22 @@ \subsection{基本関数} \end{refdesc} +\subsection{拡張された数字} +\begin{refdesc} + +\classdesc{ratio}{extended-number}{(numerator denominator)}{ +有理数を記述する。} + +\methoddesc{:init}{num denom}{ +有理数のインスタンスを、分子{\em num}分母{\em denom}として初期化する。} + +\classdesc{complex}{extended-number}{(real imaginary)}{ +複素数を記述する。} + +\methoddesc{:init}{re im}{ +複素数のインスタンスを、実部{\em re}虚部{\em im}として初期化する。} + +\end{refdesc} + \newpage diff --git a/doc/jlatex/jgenerals.tex b/doc/jlatex/jgenerals.tex index 3e43c54ae..fbafe3f36 100644 --- a/doc/jlatex/jgenerals.tex +++ b/doc/jlatex/jgenerals.tex @@ -34,6 +34,7 @@ \subsection{数値} しかしながら、数値は決してヒープメモリを無駄にすることがないため、 数値を扱うアプリケーションでは、ガーベージコレクション の原因とならず有効に動作する。 +有理数や複素数など、別の数字の型はEusLispのオブジェクトとして記述される。 EusLispは、文字型を持たないため、文字列はintegerで表現される。 文字コード表と無関係なプログラムを書くためには、 diff --git a/doc/jlatex/jintro.tex b/doc/jlatex/jintro.tex index 69ff923b2..cc510f52d 100644 --- a/doc/jlatex/jintro.tex +++ b/doc/jlatex/jintro.tex @@ -142,7 +142,7 @@ \subsection{Common Lispとの互換性} \item 多値変数: multiple-value-call, multiple-value-prog1, etc. \item いくつかのデータ型: - complex number, bignum, ratio, character, deftype + bignum, character, deftype \item いくつかの特殊書式: progv, compiler-let,macrolet \end{enumerate} diff --git a/doc/latex/arith.tex b/doc/latex/arith.tex index 669db8828..3fe352a5f 100644 --- a/doc/latex/arith.tex +++ b/doc/latex/arith.tex @@ -321,4 +321,21 @@ \subsection{Trigonometric and Related Functions} \end{refdesc} +\subsection{Extended Numbers} +\begin{refdesc} + +\classdesc{ratio}{extended-number}{(numerator denominator)}{ +Describes rational numbers.} + +\methoddesc{:init}{num denom}{ +initializes a rational number instance with numerator {\em num} and denominator {\em denom}.} + +\classdesc{complex}{extended-number}{(real imaginary)}{ +Describes complex numbers.} + +\methoddesc{:init}{re im}{ +initializes a complex number instance with real part {\em re} and imaginary part {\em im}.} + +\end{refdesc} + \newpage diff --git a/doc/latex/intro.tex b/doc/latex/intro.tex index 539f0d8e1..d307605ba 100644 --- a/doc/latex/intro.tex +++ b/doc/latex/intro.tex @@ -218,8 +218,8 @@ \subsection{Compatibility with Common Lisp} multiple-value-call,multiple-value-prog1, etc., are present only in a limited way; \item some of data types: - complex number, bignum, character, deftype and ratio (this last - one is present only in a limited way as well); + bignum, character, deftype, complex number and ratio (the last + two are present only in a limited way); \item some of special forms: progv, compiler-let,macrolet \end{enumerate} diff --git a/doc/latex/types.tex b/doc/latex/types.tex index 1343abe9a..7793c4e33 100644 --- a/doc/latex/types.tex +++ b/doc/latex/types.tex @@ -5,25 +5,26 @@ \section{Data Types} Any variable can have any object as its value. Of course, it is possible to declare the type of object which is bound to a variable, but in many cases -it is only advisary information to the compiler to generate faster code. +it is only advisory information to the compiler to generate faster code. In EusLisp, it needs to distinguish pointers and objects. Numbers are immediately represented by pointers and all the others -are represented by ojbects referenced by pointers. +are represented by objects referenced by pointers. \subsection{Numbers} There are two kinds of numbers, that is, integer and float (floating-point number), both are represented with 29 bits value and 1 bit sign. -Thus, intergers range from -536,870,912 to 536,870,911. -Floatings can represent plus/minus from 4.8E-38 to 3.8E38 with the +Thus, integers range from -536,870,912 to 536,870,911. +Floats can represent plus/minus from 4.8E-38 to 3.8E38 with the approximate accuracy of 6 digits in decimal, i.e., floating-point epsilon is about 1/1,000,000. -Numbers are always represented by pointers, and not by objects, -this is the only exception of EusLisp's object orientation. +Integer and float numbers are always represented by pointers, and not by objects, +which is the only exception of EusLisp's object orientation. However, since numbers never waste heap memory, number crunching application runs efficiently without causing garbage collection. +Other number types such as ratio and complex numbers are normal EusLisp objects. EusLisp does not have the character type, and characters are represented by integers.