Slava, Thanks for a quick and thorough response. Speaking of functional style, in languages such as Clean, one can implement functional data structures that are always persistent, that is, an update of these structures does not destroy the existing version, instead a new version is created which is coexistent with the previous version. This allows for sharing of common data. A common example would be the concatenate operation on lists where the first and last cell of the list are maintained in order to support an 0(1) time. In a functional data structure one would make a copy of the first list changing the next pointer (or equivalent) of the last cell to point to the second list, thus sharing the second list, and the two lists still exist in their original form. Is this something that is easily achievable in Factor?
I am quite impressed with the whole Factor environment, the language, the UI, emacs integration and the extremely large number of very useful libraries. I did a lot of Smalltalk programming in the early 1990s and the Factor UI (IDE?) is reminiscent of the smalltalk development environment. I don't know of any other language with as much to offer. Where does the team get all of the time to develop this? Thanks, Mike --- On Sun, 2/15/09, Slava Pestov <[email protected]> wrote: > From: Slava Pestov <[email protected]> > Subject: Re: [Factor-talk] Questions from a newbie > To: [email protected] > Date: Sunday, February 15, 2009, 10:13 PM > On Mon, Feb 16, 2009 at 12:01 AM, Mike Moretti > <[email protected]> wrote: > > > > Hello, > > I am new to factor and want to use it to develop CAD > tools. I have developed CAD tools for years in other > languages such as "C" and scheme. > > Great, welcome to the community. > > > I will have a lot of instances of tuples with slots > containing, what I would call, references to instances of > other tuples. Does Factor have a similar concept of a > reference (I.E. pointer)? > > Yes. Conceptually, all values are references in Factor. > Operations > like 'dup' don't copy objects, they just copy > references. If you want > value semantics, you have to explicitly construct new > objects or use a > word such as 'clone'. > > > That is, if I have an instance of a tuple on the stack > and I place it into the slot of another tuple will a copy be > placed? > > No, a reference to that tuple will be placed. Slot setter > words >>foo > never copy objects implicitly. > > Note that this only matters if you're mutating objects. > If you write > code in a more functional style, you won't have to > worry about copying > objects -vs- passing references as much. > > > I noticed the refs vocabulary, is that something I > should be using? That is, store a ref to an instance of a > tuple? > > The refs vocabulary is something else. > > > Also, I want to define these slots such that only > references to the correct tuple can be placed in them. I saw > that I could make a predicate class which checks the class > type and use the predicate class as the type of these slots. > Is this the best way? > > You don't have to define a new predicate class. You can > just use a > tuple class. For example, > > TUPLE: point x y ; > > TUPLE: triangle { a point } { b point } { c point } > > If you wanted to, you could elaborate the types of the > point too, > > TUPLE: point { x float } { y float } ; > > Predicate classes are useful if you want a more complex > constrant. For > example, suppose you wanted to define a type for polygons, > > TUPLE: polygon { points array } ; > > But you might want to ensure that only a non-empty array is > ever > placed there. So you'd define a predicate class, > > PREDICATE: non-empty < array empty? not ; > > TUPLE: polygon { points non-empty initial: { { 0 0 } } } ; > > Of course, this is probably overkill for this particular > example, but > the possibility exists. > > Slava > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, > San Francisco, CA > -OSBC tackles the biggest issue in open source: Open > Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open > source participation > -Receive a $600 discount off the registration fee with the > source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
