TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
101 stars 32 forks source link

Basic String operators are needed #277

Open brice-morin opened 5 years ago

brice-morin commented 5 years ago

The + is sometimes used as a hack to concatenate strings in ThingML. This is not the intended usage of +, see #51. However, string concatenation is severely lacking in ThingML, though + is a useful hack as it works in at least JS and Java.

Having a proper concatenation operator (not necessarily with the + syntax) would make it much easier to implement simple serializers in a PIM way in ThingML.

fungiboletus commented 5 years ago

Here is some inspiration if you want to implement more operators than a fancy StringBuilder:

Most of the methods could probably go into the STL. My personal preference is Ruby, but I would not mind doing it the Go way or JS (JS is a bit too Perl IMHO). Notice that I didn't link the Java doc'.

fungiboletus commented 5 years ago

More cool string methods from Ruby On Rails for inspiration.

brice-morin commented 5 years ago

The problem is the C generator, where it can be difficult to determine automatically when strings or dynamic structure should be freed... while other languages are garbage collected. And we probably do not want malloc and free in ThingML action language...