A new, lighter syntax for Logtalk?

Suggestions for new Logtalk features

Moderator: Paulo Moura

Post Reply
Paulo Moura
Logtalk developer
Posts: 474
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

A new, lighter syntax for Logtalk?

Post by Paulo Moura » Wed Jun 18, 2014 12:32 am

Both Logtalk 2.x and the latest Logtalk 3.x beta use the ::/1-2 and ^^/2 operators for message sending and "super" calls:

Code: Select all

	current :-
		::self,
		^^super,
		object::message.
I was never truly happy about these operators but the portability constraints were, and still are, severe. Most nice looking operators are long taken and we are still limited to the venerable ASCII character set. The two most common operators used in programming languages to refer to something in a specific namespace or to send a message to an object are :/2 and ./2. The :/2 operator is the de facto standard in Prolog module systems. The changes in SWI-Prolog 7.x made the ./2 operator unavailable for anything else (when using this compiler). But a new Logtalk generation gives us an opportunity to revise design choices, including these fundamental operators. While keeping the old operators for backwards compatibility with Logtalk 2.x application code, the current idea is to switch (for new code) to:

Code: Select all

	current :-
		:self,
		^super,
		object:message.
Although these new operators are nicer, lighter, and (as far as I can tell) unlikely to cause conflicts with the supported backend Prolog compilers, they do rise two issues in the presence of module systems: (1) what syntax to use from within an object (or a category) to call a module predicate? (2) how to send a message to an object from the top-level when using a backend that implements a module system?

For entity code (1), the use_module/2 directive is already supported. The {}/1 compiler bypass control construct can also be used but with the downside of making the module predicate call invisible to the reflection API. A possible alternative is to allow a syntax such as module(m1):predicate, which would be automatically expanded to call the module predicate.

In the case of the top-level (2), the ::/2 would still be supported. A possible alternative would be support a {object:message} syntax. The {}/1 syntax is already supported at the top-level as a shortcut to the logtalk_load/1 and logtalk_make/0-1 built-in predicates. Extending it to also support the {object:message} syntax is easy but it should be noted that using the {}/1 wrapper at the top-level was never officially part of the Logtalk language specification.

I would like to know your opinion on these issues. In particular, what would be your answer to the following questions:
  • Considering new users, do you think that the proposed operators would make the language more attractive?
  • For long time Prolog users, do you think that the proposed operators would help in convincing them to try out Logtalk?
  • Do you think that the existing operators are acceptable and switching to new ones is not worth the hassle?
  • Do you think that the necessary workarounds to call module predicates from within entities and to send messages to objects from the top-level nullify the expected benefits of the new operators?
  • Are there other workarounds for (1) and (2) that should be considered?
Your feedback is most appreciated and can help shape the third generation of Logtalk.

Thanks,
Paulo Moura
Logtalk developer

rausm
Posts: 1
Joined: Fri Dec 04, 2015 7:39 pm

Re: A new, lighter syntax for Logtalk?

Post by rausm » Wed Dec 16, 2015 7:30 pm

Hello,

Let me start by stating that I'm no Prolog guru. But since new programming languages are my favorite food, hopefully that makes me at least a bit qualified ;-).

[*] Considering new users, do you think that the proposed operators would make the language more attractive?

Hard to say. Some will say so, but people who can see beyond "petty syntax" won't care. Prolog is different enough (from mainstream, as are most languages worth learning ;-)), so different notation doesn't IMO stand out [as much] as in cases when you are trying to mimic another language [closely].

[If things stayed as they are, and] If "excusing the difference" was deemed necessary/helpful (perhaps to foster the notion / auto-answer "we are different but we know why"), I'd state in the "Message sending" part of the manual (perhaps in footnote ?) that :: was chosen beacause : is for modules, that ^^ was chosen for symmetry, that no better alternative was found (link to place describing things that need to be considered, feel free to discover a better way) and be done with it ;-).

[*] For long time Prolog users, do you think that the proposed operators would help in convincing them to try out Logtalk?

IMO again depends on the person (and I wouldn't care that much for people who are swayed by such trivial differences). Personally, I'd tell "notation palladins" to learn (by use) Lisp, Haskell, Smalltalk, Forth (or Factor) and Rebol (or Red) - to name a few pleasantly different languages - before they'll get the privilege to whine further ;-).

[*] Do you think that the existing operators are acceptable and switching to new ones is not worth the hassle?

Yes (or even YES ;-)).

[*] Do you think that the necessary workarounds to call module predicates from within entities and to send messages to objects from the top-level nullify the expected benefits of the new operators?

Since I lack any experience with Logtalk (beyond reading the thesis and manual, and admiring the wonderful elegance & flexibility), I lack metrics, but unless [explicitly] calling module predicates is very rare, the module(xxx):xxx notation does indeed seem too costly to me.

wrt. "... can also be used but with the downside of making the module predicate call invisible to the reflection API"
- I wouldn't want this to be the default way.

[*] Are there other workarounds for (1) and (2) that should be considered?

I excercise my right to remain silent ;-).

PS: Thank you both for Logtalk and your SWI Prolog contributions (be it code or insight).

Paulo Moura
Logtalk developer
Posts: 474
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: A new, lighter syntax for Logtalk?

Post by Paulo Moura » Tue Dec 22, 2015 1:02 pm

Thanks for your feedback and sorry for the late reply. As you now by now, I decided to make no changes to message sending and super call operators for Logtalk 3.x. If anything changes in this regard, it would not land before the fourth generation of Logtalk. Going from ASCII to Unicode would greatly wide the selection of possible operators but, sadly, that's not going to be feasible in the foreseen future.

P.S. Great to know that you enjoy Logtalk :-)
Paulo Moura
Logtalk developer

sergioc78
Posts: 1
Joined: Wed May 09, 2012 9:57 pm

Re: A new, lighter syntax for Logtalk?

Post by sergioc78 » Wed Jan 18, 2017 1:44 pm

Hi Paulo,

Any plans of coming back to this topic for the 4th generation of Logtalk ? Indeed a lighter syntax will help to make the language more appealing !

Sergio

Paulo Moura
Logtalk developer
Posts: 474
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: A new, lighter syntax for Logtalk?

Post by Paulo Moura » Thu Jan 19, 2017 3:12 pm

Possibly. It will depend on the supported backend Prolog compilers at that time.
Paulo Moura
Logtalk developer

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest