On Thu, Mar 13, 2014 at 6:13 AM, Nick Wellnhofer <[email protected]> wrote:
> One feature I'd like to implement is to ignore .cfh
> files from parcels that are not required by the current project.
+1
> It would be
> easier to determine which parcel a file belongs to if only a single parcel
> statement was allowed at the top of a file.
+1
> (Ultimately, we might want to put all the .cfh files of a parcel in a
> separate directory to support the installation of multiple versions in
> parallel.)
+1
I think we also should consider changing Clownfish to require that .cfh files
contain at most one public class and that their location within the directory
tree correspond to that class. That's a fairly significant change, but it
yields a number of benefits:
* It's easier to reason about parcels and Clownfish include dirs.
* It is always clear what .h file you need to #include within C code.
* It's possible to discover that a parcel does *not* contain a given public
class simply by inspecting the file system, rather than compiling all .cfh
files which belong to the parcel.
* Finding the .cfh file which contains a given public class is
straightforward.
With that in mind, here's one possibility for file layout within a Clownfish
include directory:
All files and directories below a .cfp file belong to the specified
parcel, unless preempted by a .cfp file in a subdirectory.
In the following directory listing, there are two packages, `foo` and
`foo.bar`:
$INCLUDE
$INCLUDE/foo
$INCLUDE/foo/bar
$INCLUDE/foo/bar/Gizmo.cfh
$INCLUDE/foo/bar.cfp # parcel foo.bar
$INCLUDE/foo/Thing.cfh
$INCLUDE/foo/Widget.cfh
$INCLUDE/foo/defs.h
$INCLUDE/foo.cfp # parcel foo
The files `Thing.cfh` and `Widget.cfh` belong to the parcel `foo`, as does
the C header file `defs.h`.
The file `Gizmo.cfh` belongs to the parcel `foo.bar`.
For the sake of argument, here's another possible layout which supports
multiple versions per past discussions.
$INCLUDE
$INCLUDE/foo
$INCLUDE/foo/bar/0
$INCLUDE/foo/bar/0/Gizmo.cfh
$INCLUDE/foo/bar/0/_parcel.cfp # parcel foo.bar 0.x
$INCLUDE/foo/bar/1
$INCLUDE/foo/bar/1/Gizmo.cfh
$INCLUDE/foo/bar/1/_parcel.cfp # parcel foo.bar 1.x
$INCLUDE/foo/1/Thing.cfh
$INCLUDE/foo/1/Widget.cfh
$INCLUDE/foo/1/defs.h
$INCLUDE/foo/1/_parcel.cfp # parcel foo 1.x
Honestly, I may be ready to give up on that feature. As much as I think that
library versioning is a pressing problem in the world of computer science,
supporting multiple library versions simultaneously at runtime is very
involved and not central to the mission of a "symbiotic object system". Maybe
we just make incremental progress on the versioning problem by formalizing the
format and ordering of Clownfish version numbers and call it a day.
Another related issue is that we want to allow the parcel `com.example.stuff`
to be located at the top of a source directory, in order to avoid
inconveniently deep source trees (such as those which afflict many Java
projects). How about we support that by searching two places for the .cfp
file corresponding to the parcel `com.example.stuff`?`
1. `$INCLUDE/com/example/stuff.cfp`
2. `$INCLUDE/com.example.stuff.cfp`
Such behavior would facilitate development directory trees like this:
core
core/com.example.stuff.cfp
core/com.example.stuff.tripe.cfp
core/stuff
core/stuff/Doodad.c
core/stuff/Doodad.cfh # class com.example.stuff.Doodad
core/stuff/Gadget.c
core/stuff/Gadget.cfh # class com.example.stuff.Gadget
core/tripe
core/tripe/Junk.c # class com.example.stuff.tripe.Junk
core/tripe/Junk.cfh
The deep directory structure would be checked first. A parcel file named
`com.example.stuff.cfp` would be installed as `com/example/stuff.cfp`.
I can elaborate on the rationale for that proposal in another email.
> Another thing I'd like to do is to get rid of the "default" parcel.
So... every .cfh file will need to start with a parcel statement?
+0
It's a little more boilerplate for simple stuff but OK. It's also something
which could theoretically be relaxed later.
The CFC implementation code for the "default" parcel is pretty kludgy IIRC, so
I'm guessing at least part of the motivation is cleanup? Go for it.
Marvin Humphrey