Skip to content

Commit cd2b7b9

Browse files
authored
document core int/float fns difference with clojure (#877)
Hi, I've document the differences of the `int` and `float` functions from Clojure. It resolves #875. Do we need a changelog entry for this? Thanks Co-authored-by: ikappaki <[email protected]>
1 parent 4178c21 commit cd2b7b9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

docs/differencesfromclojure.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ Libs
150150

151151
Support for Clojure libs is `planned <https://github.com/basilisp-lang/basilisp/issues/668>`_\.
152152

153+
.. _core_lib_differences:
154+
155+
basilisp.core
156+
-------------
157+
158+
- :lpy:fn:`basilisp.core/int` coerces its argument to an integer. When given a string input, Basilisp will try to interpret it as a base 10 number, whereas in Clojure, it will return its ASCII/Unicode index if it is a character (or fail if it is a string).
159+
160+
- :lpy:fn:`basilisp.core/float` coerces its argument to a floating-point number. When given a string input, Basilisp will try to parse it as a floating-point number, whereas Clojure will raise an error if the input is a character or a string.
161+
153162
.. _refs_and_transactions_differences:
154163

155164
Refs and Transactions

src/basilisp/core.lpy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,12 +1604,16 @@
16041604
(python/float x))
16051605

16061606
(defn ^:inline float
1607-
"Coerce ``x`` to a float."
1607+
"Coerce ``x`` to a float.
1608+
1609+
If ``x`` is string, it is parsed as a floating point number."
16081610
[x]
16091611
(python/float x))
16101612

16111613
(defn ^:inline int
1612-
"Coerce ``x`` to an integer."
1614+
"Coerce ``x`` to an integer.
1615+
1616+
If ``x`` is string, it is parsed as a base 10 number."
16131617
[x]
16141618
(python/int x))
16151619

0 commit comments

Comments
 (0)