| Ticket UUID: | 2220156 | |||
| Title: | Several questions about Snit objects | |||
| Type: | RFE | Version: | None | |
| Submitter: | arjenmarkus | Created on: | 2008-11-04 07:43:48 | |
| Subsystem: | snit | Assigned To: | duquette | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2026-11-21 11:06:49 | |
| Resolution: | Works For Me | Closed By: | serhiy.storchaka | |
| Closed on: | 2026-11-21 11:06:48 | |||
| Description: |
I have a few questions on Snit objects (see: http://wiki.tcl.tk/2831 for some details - the example near the end) 1. Is it possible to _clone_ an object? I ask because I want to "chain" methods from various objects. In my example: to combine different transformations into a single one. 2. Is the command install only available at creation time? If not, I would like to use it to vary the components after the object has been created, to make its behaviour more dynamic. 3. Is the delegate command only available when defining the type? (The reasons for questions 2 and 3 are that I would like some dynamic behaviour of the objects, beyond options and variables. Mostly, perhaps, because I am experimenting with Snit, to get a feel for the style of programming) | |||
| User Comments: |
serhiy.storchaka added on 2026-11-21 11:06:49:
1: there is no built-in cloning (see aku's answer). 2: install also works after construction, e.g. from a method; delegated methods then use the new component. 3: delegate is only available in the type definition. andreas_kupries added on 2008-11-05 00:13:41: Ad 1. Cloning is essentially a serialize+deserialize operation. Using snit introspection it should be possible to automate basic support for this, maybe even in a snit::macro. Note, this implies that currently there is no such support in snit, AFAIK. Now further, if the object to clone is more complex, like using timers, sockets, files, i.e. any type of state which is not stored directly in the object, the basic clone will not be enough. For these cloning will need custom written support code which handles all the complex parts.
Ad 1. The struct::{graph,tree} structures in Tcllib, while not based on snit, contain '(de)serialize' methods, fully custom written, and assignment/copy methods on top, even with support for copy during construction.
Ad 2. No idea, defering to Will for that.
Ad 3. No idea, defering to Will for that.
| |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki