Commit graph

1638 commits

Author SHA1 Message Date
yorickhardy
2b0f0601a6
Raise errors and objects with different tags (#557)
* tests/base.scm: add two tests for issue #556

The two tests are adapted from issue #556 (originally from r7rs).
The tests currently fail because errors and raised objects are
treated in the same way.

* Use different tags for raised objects and raised errors

The behaviour for raising an error (error message irritants) and
objects (raise object) are different in r7rs. So tag error objects
differently, and adjust the raised object handling to handle
the raised object instead of a list containing the raised object.

This should resolve issue #556.

* runtime: use the correct string length for comparison

Fix for the pull request adressing issue #556.

* runtime: distinguish exceptions and errors in default handler

* repl: use error-object? to decide whether an error or an exception was raised

This makes error messages a bit more informative.  Also, if error objects become
a distinct type, then the repl implementation will continue to be correct. The
(deleted) second cond clause seemed to be bit redundant - I am not sure what the
original intent was.

* tests/base.scm: revert accidental deletion of else clause

* Display exceptions as errors for consistency
2025-02-23 16:23:16 -05:00
Justin Ethier
c325a8a8e5 Issue #552 - Add 'else' clause for cond-expands 2025-01-18 10:38:35 -08:00
Justin Ethier
2d833cd6c1
552 cond expand no match (#554)
* Issue #552 - Error if no match cond-expand clause

* Issue #552 - Document change to cond-expand
2025-01-16 22:31:08 -05:00
Justin Ethier
398f8e91d6 Update copyright to 2025 2025-01-01 18:02:01 -08:00
Justin Ethier
06219634e9 Issue #537 - Add useful comments 2024-05-21 18:41:41 -07:00
Justin Ethier
1ce4979658 Testing fix for issue #537 2024-05-20 19:31:38 -07:00
Justin Ethier
0a062177f7 Issue #534 - Bug fix for beta exp bug
Perform full scanning of function application list to ensure self-recursive calls are found. This prevents infinite loops in the beta expansion code when compiling simple recursive calls.
2024-04-02 18:54:15 -07:00
Justin Ethier
82b0f9f3e2 Cleanup 2024-03-14 19:42:42 -07:00
Justin Ethier
6068b30ded Issue #530 - Handle parsing of +i / -i 2024-03-13 19:31:58 -07:00
Justin Ethier
887e1e5aa9 Return fixnum if sqrt(fixnum) is an exact int 2024-03-12 19:06:54 -07:00
Justin Ethier
32af1bcd05 Removing top-level sqrt
This isn't good enough, there are going to be bootstrap compilation problems undoing this...
2024-03-11 19:29:54 -07:00
Justin Ethier
a2568d8589 Allow inline sqrt 2024-03-11 19:29:44 -07:00
Justin Ethier
fa6213b907 Issue #530 - First cut at improving sqrt
Improving sqrt to properly handle negative parameter values
2024-03-11 19:19:12 -07:00
Justin Ethier
37b39693ed Bump to 0.37.0 2024-03-05 17:54:06 -08:00
Yorick Hardy
4bbceeb4d6 round half-integers to even instead of away from zero
This changes the behaviour to match r7rs (round x) instead of C round(x).

An answer to https://stackoverflow.com/questions/32746523/ieee-754-compliant-round-half-to-even
suggests using remainder(). The following will work if FE_TONEAREST is defined, but C11
requires FE_TONEAREST to be defined if and only if the implemenetation supports it in
fegetround() and fesetround() [Draft N1570]. On the other hand, remainder() must be defined.
C23 will have roundeven(), but this is not yet available on all platforms.
The behaviour of remainder is described in Draft N1570, page 254, footnote 239.

Alternative implementation:

  double round_to_nearest_even(double x)
  {
  #pragma STDC FENV_ACCESS ON
    int mode;
    double nearest;
    mode = fegetround();
    fesetround(FE_TONEAREST);
    nearest = nearbyint(x);
    fesetround(mode);
  #pragma STDC FENV_ACCESS OFF
    return nearest;
  }
2024-02-01 22:25:47 +02:00
Justin Ethier
e4992492b3 Add stub for rationalize 2024-01-08 18:26:38 -08:00
Justin Ethier
43923a6e44 Issue #519 - Allow truncate-quotient to return fixnums
Return a fixnum when fixnum args are received, per R7RS.
2024-01-06 14:37:36 -08:00
Justin Ethier
92d5d80cc1 Added TODO 2024-01-06 09:25:26 -08:00
Justin Ethier
14a561a40f Adding TODO's 2024-01-02 19:00:23 -08:00
Justin Ethier
5f77e6de3d Update year 2024-01-02 18:03:53 -08:00
Justin Ethier
334787b6d6 Issue #517 - Raise error when reading invalid number
Previously #f was returned in this case but it is more correct to raise an error instead. This prevents weird edge cases and is more consistent with other schemes.
2023-12-05 18:14:52 -08:00
Justin Ethier
abaed9f6f2 Issue #510 - Implement exact using runtime functions 2023-09-12 19:20:38 -07:00
Justin Ethier
3e3f0114e5 abs computes magnitude for complex nums
Instead of raising an error use C99 function to compute the magnitude instead. This is more useful and seems more correct as well.
2023-09-11 19:13:08 -07:00
Justin Ethier
f8fbb9ad7d WIP, fixing bugs with double ops
Allow round/ceil/floor/truncate to properly handle doubles.

Need to handle more edge cases with (exact).
2023-09-06 19:41:57 -07:00
Justin Ethier
cc5d1d5d65 WIP 2023-09-05 19:04:18 -07:00
Justin Ethier
fd56e21e90 Issue #506 - abs returns an error for complex nums 2023-08-15 18:46:30 -07:00
Justin Ethier
cb67aeb0a3 Issue #501 - odd/even must receive an integer
Raise an error if a decimal number is passed to these primitives.
2023-03-03 16:08:12 -08:00
Justin Ethier
76668dc76c Update version number, year 2023-01-03 12:15:42 -08:00
Justin Ethier
bd044a3237 Clean up variable names 2023-01-03 12:15:30 -08:00
Justin Ethier
f728618336 Issue #498 - read-line can read 1022+ byte lines
Previously the function would only read up to the first 1022 bytes. We now remove that restriction
2022-12-20 21:44:27 -05:00
Justin Ethier
ab25e360a9 Merge #497 2022-12-09 13:29:56 -08:00
Justin Ethier
ad1ac3a135 Issue #490 - Proper assv and memv implementations
Both were previously implemented in terms of `assq` and `memq`, respectively.
2022-07-24 10:56:41 -04:00
Justin Ethier
f8555f796d Issue #489 - Guarantee order of eval begin exprs
Guarantee that sub-expressions of a begin are evaluated in order. The code was reversing the results of a map. However map is not necessarily guaranteed to evaluate its arguments in any given order because it could be optimized into another function such as `Cyc-map-loop-1`. Instead we just use the optimized function directly as a more general `map` is not required here and this function is guaranteed to process its argument list in a predicable order.
2022-07-21 21:41:47 -04:00
Justin Ethier
6ffd229dcd Add memory-streams to list of features 2022-05-28 08:21:11 -07:00
Justin Ethier
6d58017620 Version bump 2022-05-26 16:52:42 -04:00
Justin Ethier
2d7a9968e8 New release 2022-01-02 16:54:03 -05:00
Justin Ethier
ff6a11042e Prep release 2021-09-24 18:34:01 -07:00
Justin Ethier
9d130722d6 Do not inline calls to system 2021-09-07 08:24:08 -04:00
Justin Ethier
f8717517a4 Issue #480 - Make (expand) easier to use
Only require a single expression argument. The remaining environment arguments are generally not required when debugging from the REPL. This makes expand much easier to use for casual debugging.
2021-08-25 17:47:55 -04:00
Justin Ethier
140f26ebe9 Prep new release 2021-08-11 09:40:46 -04:00
Sören Tempel
e3d7b6eed9 Flush current-output-port after writing prompt to it
On Unix-like operating systems stdio.h (which Cyclone seems to use
internally) is line-buffered. As such, the prompt will only be written
after a newline character is written (since the prompt itself doesn't
contain a newline) which is probably not what was
intended here. This commit fixes this issue by always flushing the
current-output-port after writing the prompt string.
2021-08-03 11:36:14 +02:00
Justin Ethier
dd294c78ad Issue 395 - Cleanup, use _expand instead of macro:expand 2021-07-29 22:58:29 -04:00
Justin Ethier
5911336d16 WIP - first attempt to clean eval macro's
This seemed promising but fails when compiling cyclone:

    cyclone -A . srfi/106.sld
    Error at line 376, column 5 of srfi/106.sld: Unbound variable:
    unquote
2021-07-27 16:39:13 -04:00
Justin Ethier
95c3fea24f Issue #433 - Working numerator/denominator 2021-07-22 17:12:56 -04:00
Justin Ethier
f17102178b Continue building-out new numerator/denominator 2021-07-21 19:47:42 -07:00
Justin Ethier
a3e0d51021 Issue #273 - Avoid compiler warning 2021-07-19 19:45:34 -07:00
Justin Ethier
29033581ad Issue #467 - Allow passing negative value to make-list
This should result in an empty list, NOT consume all available resources!
2021-07-19 17:04:52 -04:00
Justin Ethier
c58a9927ae Issue #404 - Do not require all fields to be listed in constructor 2021-07-19 16:56:06 -04:00
Justin Ethier
92aeec6a2e Issue #465 - Avoid trigraphs in compiled strings 2021-07-15 16:45:42 -04:00
Justin Ethier
867b60bb14 Increment version number 2021-07-15 09:46:12 -04:00