More questions 
Author Message
 More questions

Quote:

> 2) Can a function be written which searches the slots of all the objects
> of a certain class to find a certain value, and which returns that
> object as a value:

> find-me(<man>, height == 75")

Dylan does not automatically maintain a collection of all the instances of
a given class.  You can do that yourself, using an initialize method and
whatever subclass of <collection> you like, and then scan that collection
in your find-me function.  For example, you could make a <table> keyed by
some attribute of your object, and find-me could look in that table.  Or
you could make a <list> of all your objects, and find-me could check them
one by one.

To say the same thing in other words, Dylan is a programming language, not
a database.

Note that all the builtin collection types, and any you could define
yourself in a portable way, will prevent an object in the collection from
being reclaimed even if it is otherwise unreferenced.  Whether this is a
problem depends on your application.  If you know when you are done with
an object, you can remove it from the collection of all objects
explicitly.

Quote:
> If anybody knows how I can direct the flow of my program from instance
> number x of <example-object> to instance number z of <example-object>,
> please, please tell me.

If your instances are numbered, you can create a <vector> keyed by the
numbers, whose elements are your instances.

But, stepping back a bit, your questions suggest to me that you're not
thinking about objects in the way that Dylan expects you to.  Dylan is not
a relational database.  If you're using "ids" instead of directly
referring to objects, this may be a sign of "incorrect" thought.  When I
say "incorrect", I don't mean there is anything wrong with you, it's just
that your way of thinking doesn't match Dylan's way of thinking.  If one
object has a second object that is related to it, put a slot in the first
object whose value is the second object.  Don't go indirectly through
tables keyed by IDs, unless you have to.

You might find it worth your while to read a Dylan Programming textbook.
At this level, even a Java or C++ or CLOS or Objective C or Smalltalk
textbook would help, since all of those languages think of objects in a
way similar to how Dylan thinks of them.
--Dave Moon



Tue, 22 Jun 1999 03:00:00 GMT  
 More questions

Quote:

>1)  Is it possible for a function to return one among many objects of
>the same class, such as:

>get-me(part-number: 5)

>2) Can a function be written which searches the slots of all the objects
>of a certain class to find a certain value, and which returns that
>object as a value:

>find-me(<man>, height == 75")

If I understand these questions correctly, you want to have get-me and
find-me have access to all instances of some class, e.g. <man>. There is no
built-in mechanism for getting all the instances of some class (e.g. no
all-instances-of function exists). However, for a given class, you may be
able to build it yourself. Simply define a global variable which will be
the collection to hold all the instances. Then, define an initialize method
which adds the new instance to the collection. Any time you need to access
all instances, simply iterate the collection.

This solution has the major disadvantage that no instances of your class
will ever be deleted (because the collection will always reference them).
So, this solution may not be appropriate for your specific problem.

--
------------------------------------------------------------------------
Eric Berdahl                "No job is too big.
Man Behind the Curtain       No fee is too big."
Intelligent Paradigm                - Dr. Peter Venkman, "Ghostbusters"




Tue, 22 Jun 1999 03:00:00 GMT  
 More questions

    David> Note that all the builtin collection types, and any you
    David> could define yourself in a portable way, will prevent an
    David> object in the collection from being reclaimed even if it is
    David> otherwise unreferenced.  Whether this is a problem depends
    David> on your application.  If you know when you are done with an
    David> object, you can remove it from the collection of all
    David> objects explicitly.

I plead for weak links and a termination function in the next revision
of the Dylan language.

Andreas

--
BeBox - the psychedelic trance computer.



Wed, 23 Jun 1999 03:00:00 GMT  
 More questions



Quote:
>You might find it worth your while to read a Dylan Programming textbook.
>At this level, even a Java or C++ or CLOS or Objective C or Smalltalk
>textbook would help, since all of those languages think of objects in a
>way similar to how Dylan thinks of them.

In fact, are there *any* OO languages that automatically maintain
collections of all the objects of a particular class, or otherwise make it
easy to perform the type of inverted searches that the original poster
asked about?
--
Barry Margolin
BBN Planet, Cambridge, MA

(BBN customers, please call (800) 632-7638 option 1 for support)


Wed, 23 Jun 1999 03:00:00 GMT  
 More questions

Quote:


> >You might find it worth your while to read a Dylan Programming textbook.
> >At this level, even a Java or C++ or CLOS or Objective C or Smalltalk
> >textbook would help, since all of those languages think of objects in a
> >way similar to how Dylan thinks of them.

> In fact, are there *any* OO languages that automatically maintain
> collections of all the objects of a particular class, or otherwise make
it
> easy to perform the type of inverted searches that the original poster
> asked about?

Certainly SmallTalk does. Perhaps also CL, but I'm not sure. The only
reason (I believe) that Dylan doesn't is because it specifically limits
dynamism for efficiency. On the other hand, I think the DRM specifically
mentions this type of introspection and states that an implementation may
provide (implementation-specific) mechanisms for this. I also suspect that
once there has been some experience implementating this, a standard
extension to the language may be defined.

...........................................................................
Chris Page                                       define module mail-message
Dylan Hacker                                       use dylan;
Harlequin, Inc.                                    use standard-disclaimer;
<http://www.best.com/~page/>                     end module mail-message;



Wed, 23 Jun 1999 03:00:00 GMT  
 More questions

 > In fact, are there *any* OO languages that automatically maintain
 > collections of all the objects of a particular class, or otherwise make it
 > easy to perform the type of inverted searches that the original poster
 > asked about?

Maybe not OO languages per se, but a number of Knowledge Representation
languages provide such functionality. [*]  As others have pointed out,
Databases do that as well.  In both cases, objects must be explicitly
deleted in order to free storage.

[* Shameless plug: ISI's Loom system does this, as well as most other
   languages in the KL-ONE family.]

--



Fri, 25 Jun 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Questions-Questions-Questions-Answers-Answers

2. Question(Questions, questions...)

3. Newbie Question: Realbasic Question

4. Questions Questions

5. Questions and more questions...

6. Browse Question / Report question

7. ***Data buffering question. Long post, lots of questions

8. questions, questions!

9. Questions, questions!

10. MicroWorlds Pro "QUESTION Set Size" question

11. OS/2 REXX Question (Object REXX Question Inside)

12. Doc question and Mount question

 

 
Powered by phpBB® Forum Software