From: keithv on
I've never used Snit so I hope this is trivial. I'm
using a snit class from tcllib and I'd like to modify
one simple 3 line internal (static?) command. I could
copy the source and modify it, but I'd rather keep
using the tcllib copy and modify it dynamically.

Is this possible, and if so how?

Thanks
Keith
From: Robert Heller on
At Sun, 4 Jul 2010 20:50:37 -0700 (PDT) keithv <kvetter(a)gmail.com> wrote:

>
> I've never used Snit so I hope this is trivial. I'm
> using a snit class from tcllib and I'd like to modify
> one simple 3 line internal (static?) command. I could
> copy the source and modify it, but I'd rather keep
> using the tcllib copy and modify it dynamically.
>
> Is this possible, and if so how?

Snit does not really have 'internal' ('private') *methods -- everything
is actually 'public'. People just use naming conventions to indicate
'private' methods.

If the thing you want to replace is a method (or typemethod), then you
have two options:

1) copy the source and modify it.
2) create a new snit::type and delegate everything (except the *method
you want to change) to the one in the library, with a replacement *method.

The new snit::type would either have a typeconstructor, a typecomponent,
and a replacement typemethod and/or a constructor, component, and a
replacement method. The *constructor(s) would install the *component(s)
from the original snit::type. The rest of the snit::type would be
wildcarded delegate specs.

This is similar to something like this in C++:

Some library class:

/* All methods public and virtual [effectively this is how snit works] */
class libraryclass {
public:
virtual libraryclass();
virtual ~libraryclass();
virtual int method1(...);
...
};

Replacement code:

/* myoverloadedclass replaces one method in the library class */
class myoverloadedclass : public virtual libraryclass {
public:
virtual myoverloadedclass() : libraryclass() {};
virtual ~myoverloadedclass() {};
virtual int method1(...) {<replacement code>};
};

>
> Thanks
> Keith
>

--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk


From: Keith Nash on
Robert Heller wrote:

> 1) copy the source and modify it.
> 2) create a new snit::type and delegate everything (except the *method
> you want to change) to the one in the library, with a replacement *method.

(3) Not as slick as (2), but quicker:

(a) Execute the Snit definitions for the object that you want.
(b) Overwrite the definition of the method that you need to change.

snit::method objectName methodName {arg1 arg2 ...} {
method body
}

Keith.

From: keithv on
On Jul 5, 8:46 am, Keith Nash <k...(a)citizenearth.com> wrote:
> Robert Heller wrote:
> > 1) copy the source and modify it.
> > 2) create a new snit::type and delegate everything (except the *method
> > you want to change) to the one in the library, with a replacement *method.
>
> (3) Not as slick as (2), but quicker:
>
> (a) Execute the Snit definitions for the object that you want.
> (b) Overwrite the definition of the method that you need to change.
>
> snit::method objectName methodName {arg1 arg2 ...} {
>     method body
>
> }

I like the "quicker". Will the above work for non-method
procedure? Here's a code snippet:

snit::type map::slippy::fetcher {
...
proc urlOf {tile} {
...
}
}

I have an instance of map::slippy::fetcher and I
want to modify procedure urlOf to accommodate
different url schemes.

Thanks,
Keith

From: Will Duquette on
On Jul 5, 5:58 am, keithv <kvet...(a)gmail.com> wrote:
> On Jul 5, 8:46 am, Keith Nash <k...(a)citizenearth.com> wrote:
>
> > Robert Heller wrote:
> > > 1) copy the source and modify it.
> > > 2) create a new snit::type and delegate everything (except the *method
> > > you want to change) to the one in the library, with a replacement *method.
>
> > (3) Not as slick as (2), but quicker:
>
> > (a) Execute the Snit definitions for the object that you want.
> > (b) Overwrite the definition of the method that you need to change.
>
> > snit::method objectName methodName {arg1 arg2 ...} {
> >     method body
>
> > }
>
> I like the "quicker". Will the above work for non-method
> procedure? Here's a code snippet:
>
>   snit::type map::slippy::fetcher {
>     ...
>     proc urlOf {tile} {
>       ...
>     }
>   }
>
> I have an instance of map::slippy::fetcher and I
> want to modify procedure urlOf to accommodate
> different url schemes.
>
> Thanks,
> Keith

Snit process reside in a namespace named after the type. So what
you'd do is this:

proc map::slippy::fetcher::urlOf ...