On Thu, May 7, 2015 at 12:24 PM, Nick Wellnhofer <[email protected]> wrote:
> On 07/05/2015 17:42, Marvin Humphrey wrote:
>>
>> This very large branch does not merge cleanly and is going to get harder
>> to
>> merge over time. Should we concentrate on getting it done and hold off on
>> other merges until it is in?
>
>
> I rebased the branch and started to merge it:
>
> https://github.com/nwellnhof/lucy-clownfish/commits/cfc_symbol_v3
>
> When rebasing one of the changes, I had to adjust some Go-related code:
>
>
> https://github.com/nwellnhof/lucy-clownfish/commit/ad6e08984c09aeb9664f44170135ea4fb5d9734a#diff-44d73b464e29b0aa45fd6058111dc60b
>
> Does this look OK?
What `CFCGoMethod_get_sig` does is return a signature for a Go interface
appropriate for a method declared in a Clownfish class. For example, Lucy's
TermQuery#Get_Field method yields the following signature:
GetField() clownfish.String
We use those signatures to build up Go interfaces for each class. Here's
some output taken from when we build the clownfish runtime...
type Obj interface {
Clone() Obj
Destroy()
Equals(Obj) bool
CompareTo(Obj) int32
GetClass() Class
GetClassName() String
IsA(Class) bool
ToString() String
ToI64() int64
ToF64() float64
ToBool() bool
Mimic(Obj)
TOPTR() uintptr
}
... and also from lucy:
type Query interface {
clownfish.Obj
MakeCompiler(Searcher, float32, bool) Compiler
SetBoost(float32)
GetBoost() float32
Serialize(OutStream)
Deserialize(InStream) Query
Dump() clownfish.Obj
Load(clownfish.Obj) clownfish.Obj
}
type TermQuery interface {
Query
GetField() clownfish.String
GetTerm() clownfish.Obj
}
Three items of note:
* The invocant is not part of the signature.
* Namespacing of types is a concern: `String` vs. `clownfish.String`
* Each method only appears *once*
We use the Clownfish parcel to determine how types should be namespaced.
When the parcel is clownfish, String is spelled `String`. When the parcel is
lucy, String is spelled `clownfish.String`.
There are two things that are weird about the patch.
1. The sig is cached, but should arguably change based on the `invoker`
because that affects namespacing of types.
2. However, we'll only need the sig once: when the method is first declared.
And when that happens, the parcel of the CFCMethod will be exactly the
same as the parcel of the CFCClass invoker.
So, I would argue that `CFCGoMethod_get_sig` does not need to be passed an
`invoker`. Instead, its documentation should be clarified:
/** Retrieve the Go interface method signature. Types will be namespaced
* to the parcel in which the method is declared.
*/
Does that make sense?
Marvin Humphrey