Re: make it so that (=? "hi" "hi") works
Sandra Snan 26 May 2021 08:13 UTC
Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> writes:
> The version with zero? is at least as performant as the version with
> (lambda (x) (= x 0)). This is highly not true for the =? case.
The perfomance contest in this case being between
(=? x y)
and
(=? (make-default-comparator) x y)
not between (=? x y) and (string=? x y)
> Again, which generic code do you have in mind where you want to code
> something like (map =? xs ys) and where using a user-supplied comparator
> argument is not the better solution?
For example (count =? xs ys) to see how many two objects in the same
position match. Monster sprites vs player sprites in a video game for
example.
> While I would rather spell (+ x 1) in full, I agree that versions with
> fixed arguments can be useful. For example, make-hash-table with a fixed
> eq-comparator argument (e.g. make-eq-hash-table) can be seen as useful.
Similarly,
(define (apply-default-discount x)
(* (default-discount-factor) x))
can be useful in business logic. In other words, fixed arguments can be
both dynamic and useful at the same time.
> Again, Scheme is not
This is a list about what Scheme should be.
And my pov in that discussion is that having a comparator argument here
makes the entire idea of registering a default comparator pointless.
> Python.
I do not appreciate being associated with Python. I've used Scheme all
my life.
People come to Scheme for different reasons and appreciate different
aspects of it. I enjoy a homoiconic language (sexps and macros) with the
same namespace for car and cdr.
> PS: For this use, something like
>
> =?/default
>
> would suffice while leaving the SRFI 128 specification of =? intact.
I wouldn't mind =?/with-comparator for the version that had the explicit
comparator arg.
I am going to unsubscribe.
To the extent that the semantics of the short names is already eternalized
into stone, my participation here is useless.
To the extent that they are still up for discussion, I've said what I
want them to be.