[SVN] r6591 (OCaml)

William D. Neumann wneumann at cs.unm.edu
Thu Feb 15 19:24:27 UTC 2007


On Wed, 14 Feb 2007, Thomas Aylott (subtleGradient) wrote:

>> I don't know anything about OCaml, but I have to ask: Is adding 8 
>> preference files really the best way to do that? It just sounds way too 
>> excessive.

Yes and no.

A good hunk of those were entity names that one likely wouldn't want to 
appear in the symbol list, but would get stuck there due to the settings 
in the Source bundle.  For example, in an ocamlyacc file, we would 
want to see the definitions of tokens and the definitions of the parsing 
rules, but because these items will appear as references so often in your 
grammar rules that you will end up with 25 "Plus" entries in the symbol 
list, which is pretty useless.  However, one only needs a single 
preference file for all of the entities you wish to filter out.  I just consolidated 
them this morning -- I'll check in after more tweaking this afternoon.

The rest are transforms that tag certain entities according to ther scope. 
This is necessary due in part to the different namespaces for types &
class types, and values in the language, and  partly due to some 
overloading of syntactic cues (e.g. exceptions, variants, and modules all 
start with a capital letter) -- these don't play well with the default 
settings of the Source bundle which just adds things willy-nilly (this is 
exacerbated by the overly restrictive naming standards that I've been 
chafing at a bit recently, as they force some things to fall under 
entity.name.type that shouldn't really, and thus getting default 
untransformed inclusion in the list).

This is somewhat shown by the following snippet.

module type G =
   sig
     exception F
     class ['f] f : 'f -> object val f : 'f method f : 'f end
     type 'f g = G of 'f | H of 'f f
     val f : 'f -> 'f -> 'f g
   end
;;

module F : G =
   struct
     exception F

     class ['f] f (x : 'f)=
       object
         val f = x
         method f = f
       end

     type 'f g = G of 'f | H of ('f f)

     let f x y =
       match compare x y with
       | c when c < 0 -> G x
       | 0 -> H (new f x)
       | _ -> raise F

   end
;;

Here, the entries in the symbol list (without filtering or transforming) 
are:
['f] f, ['f] f, F, F, f, f, f, F, G, G, G, G, G, H, H, H, 'f g

Ugh.  Pretty useless, no?  Granted, this is quite hyperbolic, but in many 
large programs, things like this can happen (on a somewhat less evil 
scale).  But with a bit of filtering you can distinguish the modules from 
the exceptions, hide the variants, and distinguish classes from methods 
from functions.

Now, if we had the ability to combine these transforms into a single 
preference file, that would be nice, something along the lines of:

case scope in
  [ entity.name.blah ]:
    { show = 1; transform = 's/^/blah: /'}
  [ entity.name.sniffle, entity.name.snuffle, meta.hammer.thor ]:
    { show = 1; transform = 's/^/YIPPIE! -- /'}
  [ storage.type.junk, entity.name.method.junk ]:
    { show = 0 }

might work.

William D. Neumann

---

"There's just so many extra children, we could just feed the
children to these tigers.  We don't need them, we're not doing 
anything with them.

Tigers are noble and sleek; children are loud and messy."

         -- Neko Case

Life is unfair.  Kill yourself or get over it.
 	-- Black Box Recorder



More information about the textmate-dev mailing list