Skip to content

fix: complete the Double math suite with missing C wrappers and registrations#1558

Open
sqrew wants to merge 1 commit into
carp-lang:masterfrom
sqrew:fix/dangling-double-definitions
Open

fix: complete the Double math suite with missing C wrappers and registrations#1558
sqrew wants to merge 1 commit into
carp-lang:masterfrom
sqrew:fix/dangling-double-definitions

Conversation

@sqrew

@sqrew sqrew commented May 31, 2026

Copy link
Copy Markdown
Contributor

This PR addresses several dangling definitions in the Double module where functions were registered in the Lisp layer but missing their corresponding C wrappers in carp_double.h.

Changes:

  • Added Double_tan and Double_round to carp_double.h.
  • Added C wrappers for all to-type conversion functions in carp_double.h.
  • Registered Double.round in Double.carp (matching the Float module).
  • Implemented standard interface registrations (to-int, to-float, to-long, to-uint64, to-bytes) in Double.carp.

@sqrew sqrew force-pushed the fix/dangling-double-definitions branch from b1273d2 to cda5ed9 Compare May 31, 2026 10:34
@sqrew sqrew force-pushed the fix/dangling-double-definitions branch from cda5ed9 to 887775c Compare May 31, 2026 13:19

@hellerve hellerve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more things:

  • Add tests for Double.round.
  • Reduce churn in carp_double.h. Your description says that functions were previously not defined in C, but this is not true. You just reordered them all over.

Comment thread core/Double.carp
(implements sqrt Double.sqrt)
(implements tan Double.tan)
(implements tanh Double.tanh)
(implements to-int Double.to-int)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already exists on line 59.

Comment thread core/carp_double.h
#include <string.h>

const double CARP_DBL_MAX = DBL_MAX;
const double CARP_DBL_MIN = DBL_MIN;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not registered, so currently dead code?

Comment thread core/carp_double.h
Comment on lines +1 to +2
#ifndef CARP_DOUBLE_H
#define CARP_DOUBLE_H

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don’t have this guard anywhere else.

Comment thread core/carp_double.h
Comment on lines +4 to +7
#include <float.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We rely on include order, so this is odd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants