Commit graph

286 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
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
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
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
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
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
6ffd229dcd Add memory-streams to list of features 2022-05-28 08:21:11 -07: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
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
358fe01fc2 Issue #211 - production version of (char-ready?) 2021-06-08 13:38:33 -04:00
Arthur Maciel
1d1cd8d61f Unless/when don't have alternate clause 2021-01-22 22:25:29 -03:00
Justin Ethier
b218aacf65 Clean up cruft 2020-12-22 17:03:37 -05:00
Justin Ethier
a5fb3b1b14 Allow (vector?) to recognize and disregard record types 2020-12-21 23:00:43 -05:00
Justin Ethier
cc3c8f5bac WIP refactoring record marker
Idea here is to use a new record marker that is guaranteed to be unique and that will be faster to compare against in the C runtime.
2020-12-21 21:50:07 -05:00
Justin Ethier
2c5d9eeb8d Added record-marker2 2020-12-20 22:46:27 -05:00
Sean Lynch
623f59a84d Fix a crash in record predicates
Ensures that the argument to a record predicate has enough items to be a
record before checking for the record-marker and type name.
2020-12-19 12:19:25 -08:00
Justin Ethier
e257b009c4 Merge branch 'master' of github.com:justinethier/cyclone 2020-08-18 22:14:24 -04:00
Justin Ethier
746d308a75 Fix regression in is-a? 2020-08-18 22:14:09 -04:00
Justin Ethier
36b9489507 Cleanup error message on invalid type 2020-08-17 18:15:44 -04:00
Justin Ethier
ed167c71c1 Issue #402 - Type check record type getter/setter 2020-08-17 18:01:43 -04:00
Justin Ethier
b350a0cf33 Prevent overwritting evn's when importing from repl 2020-07-27 17:53:31 -04:00
Justin Ethier
7b079d36d3 Pretty-up the top-level error messages
Make the output more readable when we have location information for the error.
2020-07-23 12:38:01 -04:00
Justin Ethier
e6d654b4a4 Prevent line number info from being added twice
Since we now call error/loc in the macro expander, it is possible we are double-calling it if a macro is also calling it directly to report a syntax error. We need to detect that case and only add location information (line, column, filename) if it has not already been added to the error message.
2020-07-23 12:23:42 -04:00
Justin Ethier
1670670968 WIP, universal macro exception handler 2020-07-23 12:10:24 -04:00
Justin Ethier
c37e8dfad9 Allow passing more args to error/loc 2020-07-22 22:54:07 -04:00
Justin Ethier
6d30e7449b Include source location in error messages 2020-07-21 23:05:32 -04:00
Justin Ethier
0d25e5e122 Clean up error messages, provide filename if able 2020-07-21 22:35:47 -04:00
Justin Ethier
de1a97fbe7 Cleanup 2020-07-21 21:45:26 -04:00
Justin Ethier
f5cf3b57ee Issue #353 - Report location info with syntax errors 2020-07-20 18:49:48 -04:00
Justin Ethier
1ff14cf605 Issue #353 - Clean up error reporting 2020-07-20 18:35:57 -04:00
Justin Ethier
f3c9874e29 WIP 2020-07-20 14:52:46 -04:00
Justin Ethier
858cac4eee Relocating source list to (scheme base) 2020-07-19 22:58:01 -04:00
Justin Ethier
346a6e4bd5 Issue #369 - Switch over to multi-arg string cmp 2020-06-04 22:48:17 -04:00
Justin Ethier
5bb83cbfc6 Added stub 2020-06-03 19:08:23 -04:00
Justin Ethier
6ace99f5bb Issue #369 - Switch out inline string cmp ops 2020-06-03 18:52:59 -04:00
Justin Ethier
972b896e2b Add placeholder 2020-05-25 18:57:55 -04:00
Justin Ethier
d7abe4f8f5 Issue #380 - Support optional args to write-string 2020-05-25 18:20:39 -04:00
Justin Ethier
ac330dfffc Issue #378 - Return void instaed of null 2020-05-19 23:12:21 -04:00