
In Sketching I attempted to make dot notation work for objects.
The notation (obj.f arg ...)
will where obj
evaluates to an object, will invoke the method f
with arguments arg ...
.
An reference to obj.f
will get the field of the object and (:= obj.f v)
will assign the value v
to the filed f
of obj
.
Now, obj
is restricted to be an identifer, but I still find the notation useful — and I like not having to use the explicit send
.
Now, I decided to add “fake” fields and methods to vectors, in order for vector.length
etc. to work. It sort of makes vectors look like objects.
Is this a reasonable compromise, between ease of use v.length
instead of (vector-length v)
versus being slightly slower?
This shows how methods and fields are added:
https://github.com/soegaard/sketching/blob/main/sketching-lib/sketching/dot-method.rkt#L620
The documentation of assignment and friends are here: https://soegaard.github.io/sketching/Reference.html#%28def._%28%28lib._sketching%2Fexports-no-gui..rkt%29._~3a~3d%29%29

Looks like a syntax bee entry to me ;) @spdegabrielle

I like it

and I think “property” is the usual OOP name for that “codes like a method, looks like a field” concept

and I think they’re generally a good idea

We do need more entries so it would be appreciated!

(codes.like a-method)
(flies.like a-banana)

This is very relevant to the discussion of . notation in @mflatt’s recent Rhombus proposal