melt-umn / silver

An attribute grammar-based programming language for composable language extensions
http://melt.cs.umn.edu/silver/
GNU Lesser General Public License v3.0
58 stars 7 forks source link

Make concise functions a modification #827

Closed krame505 closed 8 months ago

krame505 commented 8 months ago

Changes

Give concise functions a specialized translation, instead of forwarding to a lambda in a global. This allows the implementation of a concise function, like regular functions, to live in its own class with an invoke method. This makes it practical to call concise functions from java code (e.g. in the LSP implementation), and direct calls to can be optimized to call invoke directly without creating an intermediate NodeFactory. This also seems to give a slight performance boost, but I haven't tried measuring it carefully.

I went ahead and tackled this since it is blocking #822, which I would like to merge soon before any other branches are made from the current version of Silver, to avoid merge conflicts.

Documentation

This doesn't affect the (already documented) behavior of this feature at all.

Testing

Existing tests for concise functions cover this adequately.