MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: OOP experiments in Mathematica- The Stack

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38723] Re: [mg38682] Re: OOP experiments in Mathematica- The Stack
  • From: "Steve S. Shaw" <steve at shawstudio.com>
  • Date: Tue, 7 Jan 2003 07:26:17 -0500 (EST)
  • References: <av374s$g0t$1@smc.vnet.net> <200301041227.HAA24547@smc.vnet.net> <3E173418.D041203@wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

"Daniel Lichtblau" wrote:
> Yes. I actually meant "Use List" (literally, rather than e.g. STACK) for
> exactly the reason you uncover below. But your work-around is also fine.
>...
One potential advantage to using List as your head is that
> it tends to be faster when one wants to convert to a vector using
> Flatten. For your purposes this is may actually be a disadvantage
> because you want to impose strict stack functionality, and that does not
> allow for such a conversion.

That's useful advice - though advice I can't follow here.

I don't use "List" as the head for a fundamental reason:
I'm relying on the "head" to indicate what "type" of item I have.

Some such indication is fundamental to my quest to make programs that are
easy to UNDERSTAND and easy to CHANGE.

In this specific example, note that the functions have argument patterns
that say they only act on STACKs.

This is essential.  Without it - no polymorphism.

It is powerful and elegant to represent all kinds of data in lists - but
those lists should be tagged in some way.

IMO, it is important that Mathematica not discourage the use of custom
heads, by performance issues.  Fortunately, once I had a defined symbol as a
head, performance was indistinguishable from a List head, for the operations
that I need.

-- Steve S.




  • Prev by Date: Re: Re: Curious Timing Results
  • Next by Date: Re: Irreducible Polynomial over GF(2)
  • Previous by thread: Re: Re: OOP experiments in Mathematica- The Stack
  • Next by thread: Re: Re: OOP experiments in Mathematica- The Stack