Front Page All Articles Recent Changes Random Article

Contents

Concatenative language

  • ACL
  • Ait
  • Aocla
  • Breeze
  • Callisto
  • Cat
  • Cognate
  • colorForth
  • Concata
  • CoSy
  • Deque
  • DSSP
  • dt
  • Elymas
  • Enchilada
  • ETAC
  • F
  • Factor
  • Fiveth
  • Forth
  • Fourth
  • Freelang
  • Gershwin
  • hex
  • iNet
  • Joy
  • Joy of Postfix App
  • kcats
  • Kitten
  • lang5
  • Listack
  • LSE64
  • Lviv
  • Meow5
  • min
  • Mirth
  • mjoy
  • Mlatu
  • Ode
  • OForth
  • Om
  • Onyx
  • Plorth
  • Popr
  • Porth
  • PostScript
  • Prowl
  • Quest32
  • Quackery
  • r3
  • Raven
  • Retro
  • RPL
  • SPL
  • Staapl
  • Stabel
  • Tal
  • Titan
  • Trith
  • Uiua
  • Worst
  • xs
  • XY
  • 5th
  • 8th

Concatenative topics

  • Compilers
  • Interpreters
  • Type systems
  • Object systems
  • Quotations
  • Variables
  • Garbage collection
  • Example programs

Concatenative meta

  • People
  • Communities

Other languages

  • APL
  • C++
  • Erlang
  • FP trivia
  • Haskell
  • Io
  • Java
  • JavaScript
  • Lisp
  • ML
  • Oberon
  • RPL
  • Self
  • Slate
  • Smalltalk

Meta

  • Search
  • Farkup wiki format
  • Etiquette
  • Sandbox

Factor/FAQ/What's Factor like?

Why is there a distinction between words and quotations?

Words and quotations are used in different places. Factor programs are built out of words, which are just compositions of other words. Words are invoked simply by naming them. Words contain metadata about their module, source location, and other things in addition to the code. If a word is on the stack, it is called with execute. Quotations, on the other hand, are the code-data used in most combinators and are not associated with the same metadata that words are. They are invoked with call.

Is Factor purely functional, like Haskell?

No, it allows arbitrary side effects and the standard library includes several mutable data structures and imperative I/O.

Why not?

It makes things much simpler. Effects don't need to be sequenced explicitly, as in Haskell. (No one has yet implemented anything like monads or uniqueness types in Factor, but we would welcome that development.) A broader range of algorithms can be used when mutability is included. It is certainly possible to write Factor code in a purely functional way, and there are a lot of interesting possibilities to explore here. It may be possible, but no one has yet designed a metaprogramming system in a purely functional language with the degree of flexibility that Factor allows.

Why is Factor dynamically, rather than statically, typed?

For basically the same reason: it makes things more simple and flexible, allowing a high degree of metaprogramming. Additionally, a flexible enough type system for concatenative languages has not yet been designed. However, Factor 2.0 may include optional static typing, if a suitable type system can be found.

Does Factor have variables?

Yes. Most commonly, Factor uses dynamically scoped variables in the namespaces vocabulary and statically scoped ones using the locals vocabulary. The latter are local to a word, while the former are used for communication between words.

But aren't dynamically scoped variables bad?

They are, if they're used for everything by default. But usually, data is passed around using the stack. Dynamically scoped variables are used for a number of wider things where it would be awkward to pass data through the stack, such as prettyprinter settings, the state of a the XML parser, and a partially assembled array.

Why are the stack shufflers given names like dup, swap and drop? Why not just x-xx, xy-yx and x- or something like that?

It is actually possible to use shufflers of this form using a vocabulary called shufflers. However, it is very rarely used. The use of mnemonics is much more clear in almost all cases, as they can mentally represent the abstract data flow going on. For extreme cases of complicated stack shuffling, statically scoped variables in the locals vocabulary are available, but stack shuffling mnemonics like dup, drop and swap are far more clean in most cases to those familiar with the language. For complicated shufflings similar to existing mnemonics, the shuffle vocabulary is also occasionally useful, mostly in dealing with foreign functions with many arguments.

This revision created on Wed, 7 Jan 2009 19:32:51 by slava

Latest Revisions Edit

All content is © 2008-2024 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license.