4 ms·
Here is how the dot notation works in Pyffi: 1. o.f access field f of object o 2. o.f1.f2 access field f2 of ob
by soegaard 4y ago
Here is how the dot notation works in Pyffi:
1. o.f access field f of object o
2. o.f1.f2 access field f2 of object o.f1
3. (o .m a ...) invoke method m on object o wth arguments a...
4. (o .m1 a1 ... .m2 a2 ...) same as ((o .m1 a1 ...) .m2 a2 ...)
5. (o.m a ...) invoke method m on object o wth arguments a...
6. (o.m a ... .m1 a1 ...) invoke method m1 on resultof object (o.m a ...) with arguments a2 ...
The notation works nicely for method chaining:
(foo .somemethod arg1 arg2
.someothermethod arg3)
- sillysaurusx 4y agoBeautiful! How do you access a property on the result of a function call? On the other hand, that case is pretty rare. Maybe it’s worth ignoring.
- soegaard 4y agoThat's a good question. The problem is that syntactically calling a method with no arguments and accessing a field will look the same, if .f is used to access a field: (foo .m1 arg1 .m) ; m is a method name (foo .m1 arg1 .f) ; f is a field name I guess, one could introduce `_f` for field access. Right now one can use `getattr` or one can bind the result of `(foo .m1 arg1)` to an indentifier `o.` and then use `o.f`.