GEdit OPI plugin
Yves Jaradin
yves.jaradin at uclouvain.be
Mon Feb 18 15:19:05 CET 2008
Le lundi 18 février 2008 à 14:31 +0100, Simon van der Linden a écrit :
> Yves Jaradin wrote:
> > Le samedi 16 février 2008 à 23:55 +0100, Simon van der Linden a écrit :
> >> The second thing is that I don't get really well the design of the OPI
> >> functor. Why does it open an inet socket, which binds on a random port
> >> on every interface? Why not an unix one? It would be easier than reading
> >> the stdout to get a list of the port digits ;-)
> >
> > Portability. Unix sockets are, well, Unix-only and don't have much
> > support in Oz. Also the OPI functor I wrote for this gedit prototype is
> > quite generic and could be used by other plugins for other editors
> > regardless of the platform.
>
> But that means that when the socket is listening for a connexion, anyone
> can use it, not only the localhost! Isn't it any way to bind it to local
> interfaces only?
>
It should be too difficult. We just need to add a builtin for binding a
socket to localhost.
> >> I'll have a deeper look at the OPI asap, but I'm wondering if it exists
> >> some doc about the "protocol" somewhere on the Internet. Could you help me?
> >
> > Considering that the source is available and in a documented programming
> > language, yes it's kind of documented ;-)
>
> If you think that your code, with the help of the Mozart documentation
> is self-explained, you are wrong.
>
> Roughly speaking, I find your code very difficult to understand. There
> isn't any comment line, and it looks like a single bloc, with plenty of
> nested function calls ;-)
>
Well that wasn't exactly production code. Are you talking about the Oz
part, the Python part, both? If you can be a bit more specific, I can
try to explain how it's supposed to work.
> > Of course, I will help you
> > where I can. In the current/old OPI, two protocols are defined. On is
> > actuallly used but quite ad-hoc, the other is cleaner, not used and
> > incomplete. The prototype/new OPI protocol is inspired by this last one.
> > The idea is that a message is a list of strings. For this, three special
> > characters are used. One to separate messages, one to separate the
> > strings inside the message and one as an escape so that the strings can
> > contain the special characters.
>
> So far, I don't understand the use of "obscure" characters as
> delimiters. If you do escape these characters in the string you send to
> the server, why don't you use parenthesis, colon, semi-colon or so?
Because these characters are often used in the strings that we want to
transmit. By using these strange characters, often no escaping at all is
required. By the way they are not really obscure, they are ASCII escape,
unit separator and record separator.
>
> Also, why do you need three channels to get information from the OPI
> process? I only see the need of an error channel, and an output one.
> And why don't you use the stdin of this process to send information, but
> a socket instead?
>
> Briefly, why do you use a socket?
Briefly, because the stdin/stdout/stderr triplet belongs to the person
writing the Oz program. We don't want the plugin to be confused because
the user fed code like {System.showInfo "jfdbhgkdgh"} or for commands to
break because the user program tries to read stdin. Actually, there is a
similar problem (but more limited) in the Emacs OPI. Try feeding
"declare Application=foo" then do "Oz/Halt Oz".
>
> Regards,
>
Yves
More information about the mozart-hackers
mailing list