On Tue, Feb 11, 2014 at 2:23 AM, Elias Naur <
elias...@gmail.com> wrote:
>
> The problem is that I don't see how to expand the interface between Go
> programs and Go libraries without imposing unbearable ABI requirements and
> version skew problems that reminds me of the notoriously unstable C++ ABI.
> You mention passing a channel, but what types are allowing over that
> channel? Are pointers allowed? It seems to me that allowing anything
> interesting being passed you might as well allow arbitrary Go function calls
> between program and library, leading to the ABI and versioning problems.
OK, I hadn't grasped this before. You are suggesting that we should
support shared libraries but only permit a cgo style interface when
calling them. That implies that each shared library will have its own
copy of the runtime. They can pass pointers back and forth, but each
call between the libraries (or the main program and a library) will be
through a defined and exported function. There will be no way to pass
a value to another shared library and have that library call a method
that calls back to the original library. It means that when passing a
pointer to another shared library, it will be essential to keep a
pointer live in the originating library, just as we must keep pointers
live when passing them to C code.
At a slightly higher level, for calling between Go shared libraries,
one can imagine building something like the net/rpc package.
> Perhaps you (or someone else on this thread) could hint on how expanding the
> interface between two bodies of Go code might work?
At the moment I'm much less interested in how we can do something than
in figuring out what we want to do. Once we know what we want to do,
we can talk about how to do it.
>> When you talk about os.Args not being available to a library, that
>> suggests a model in which a Go shared library is being called from a
>> non-Go program. The Go shared library is going to be somehow loaded
>> into the process. In that mode, is it important to support a strict
>> dlopen/dlsym interface? For example, perhaps we can simply pass the
>> argument and environment to whatever function we use to load the
>> shared library.
>
>
> I'm not sure I understand you here, could you expand on this? In the general
> case, we don't have control over the non-Go program, in which case
> dlopen/dlsym is the way the programs loads and interface with our Go
> library.
Any interface between a non-Go program and a Go shared library has to
be based on dlopen/dlsym but it doesn't have to be restricted to that.
For example, we could say that after calling dlopen the non-Go program
is required to use dlsym to call a specific function passing specific
arguments. Or we could say that the non-Go program is required to
provide certain functions that the Go shared library can call from its
initialization code. When you say that we don't have control over the
non-Go program, you are assuming a goal, and it is the goals that I
want to talk about: you are implying that we should make it possible
to write a Go shared library that can support an arbitrary plugin
interface of a non-Go program. That's a useful goal but let's make it
explicit.
>> In short this doc is taking an implementation-centric point of view,
>> which is understandable but insufficient. We need to develop a
>> goal-oriented point of view. We don't want to implement Go shared
>> libraries as whatever happens to work. We want to decide what will be
>> useful, and then adjust that based on what we can implement.
>>
>
> I'm sorry the doc is unsatisfactory. I think the main obstacle for its
> usefulness is the Go-program/Go-library case, which I see as impractical to
> implement and inclined to leave as a non-goal. If you could allow me some
> pointers in a viable direction for that mode I'll gladly expand the
> document.
I'm sorry to be so critical, and I really do appreciate you starting
the conversation. I'm just going to keep stressing that we need to
know what we want to do before we can discuss how we are going to do
it.
Ian