mattwparas / steel

An embedded scheme interpreter in Rust
Apache License 2.0
1.12k stars 50 forks source link

`integer?` behavior #213

Closed fominok closed 4 months ago

fominok commented 4 months ago

Hello, I've noticed a behaviour incompatible with Scheme and I'm not sure whether it's intended or not:

steel> (integer? 5.0)
=> #f

racket> (integer? 5.0)
=> #t

Hence exact-integer? makes no sense anymore

mattwparas commented 4 months ago

Just seems like an oversight in the implementation, and that integer? should check if the value can be coerced to an integer. As it is now I think integer? and exact-integer? share behavior, where integer? should be more specialized:

#[steel_derive::function(name = "int?", constant = true)]
fn intp(value: &SteelVal) -> bool {
    matches!(value, SteelVal::IntV(_) | SteelVal::BigNum(_))
}

#[steel_derive::function(name = "integer?", constant = true)]
fn integerp(value: &SteelVal) -> bool {
    intp(value)
}

So I think we should have to check when it is a float if the value of the fract is 0.0

mattwparas commented 4 months ago

Fixed in #214