Concatenative topics
Concatenative meta
Other languages
Meta
Does Factor have a concurrency model?
Yes, Factor supports explicit, cooperative coroutines. A new thread can be spawned with the word in-thread
, and control is passed between threads with the yield
word. The core thread
vocabulary contains the most basic thread operations, and derived coroutine operations are in the coroutines
vocabulary.
Does Factor support multiple OS threads?
Currently, no. Factor's threading model works somewhat similarly to Erlang's, with the important difference that there is only one heap, and the runtime (virtual machine) always runs in a single OS thread. The VM isn't currently thread-safe, though it will be made so in the future. Certain language features, such as word properties, currently pose challenges for making Factor thread-safe. Because everything is run in a single OS thread and there is no direct efficiency gain, Factor threads are most useful for things like executing parallel I/O operations that involve waiting.
What's some cool feature of Factor that other languages don't support?
One small feature that comes in handy is the make
word, which assists in building sequences. Another cool feature is Factor's unique object system, related to CLOS. A third feature is the sequence and assoc protocols, allowing numbered sequences and associative mappings to be treated generically. This isn't something that's uniquely possible in Factor, but Factor's library just happens to be very well-designed here. A very interesting library is the units
library, which, due to postfix notation, looks very natural. (The calendar
library also works well with postfix.) It works very well in conjunction with a library called inverse
, which takes advantage of the properties of concatenativity to invert some of computation. Slava described some of these cool properties in a reddit comment.
What kind of foreign function interface does Factor have?
Factor's C FFI loads dynamically linked libraries (.dll, .so or .dylib) at runtime, allowing the user to avoid writing, generating or otherwise messing with C code. To learn more, read the FFI documentation, or consult Elie Chaftari's brief introduction to the FFI.
Factor also has a cocoa
vocabulary with an Objective C FFI.
Why isn't my code using alien working?
You have to makes sure the appropriate dynamically linked library is being loaded using the word add-library
. On Mac OS X, make sure that your library is compiled for the same architecture as your Factor binary; if you are running the 64-bit Factor binary, you must be using a 64-bit library, and similarly for 32-bit.
What kinds of GUI libraries does Factor support?
Factor uses a cross-platform UI library written in Factor itself, using OpenGL and a small amount of native code on each platform. The listener uses this library. See UI. There aren't any bindings to wxWidgets or Gtk yet. Gtk bindings would be doable but somewhat challenging due to their heavy use of macros and complicated structs, and a SWIG binding could be helpful in implementing them. wxWidgets bindings would be impossible right now, as alien does not support C++'s name mangling.
Why isn't Factor in the Computer Language Shootout?
We want to make Factor faster before compiling a submission. Most things are already far faster than scripting languages, but certain things need tweaking.
How do you put a Factor program into a package so it can be run easily?
Factor ships with a deploy tool which creates Mac OS X .app
packages, or as Windows and Unix executables bundled with an image and some .dll
s.
To deploy a vocabulary into an application which will run the vocabulary's main word, use the code
USE: ui.tools.deploy "vocab-name" vocab deploy-tool
Does Factor support Unicode?
There is no one meaning to the phrase "Unicode support", but there are a few things that a modern programming language is expected to support in its library: UTF-8/UTF-16 input and output, Unicode collation, Unicode-appropriate casing operations, normalization, strings can hold any Unicode code point, and support for Unicode text rendering in the UI. Of these, Factor supports all but Unicode font rendering, which should be finished before 1.0 comes out.
How do I convert a character to upper or lower case in Unicode?
This isn't a well-defined operation. For example, the ß character becomes SS in upper case. Some letters have context-dependent case mappings. So if you need to change the case of something, use strings, not individual characters. The Factor Unicode library doesn't implement character mapping, because the behavior could only be incorrect. If what you're converting is just ASCII, then there are character conversion routines defined just for that. For case-insensitive comparison, partial collation keys might be appropriate.
Can a vocabulary have sub-vocabularies?
Yes, but there's no real relationship between the main and sub vocabularies. It's just a naming/directory organization thing, and by convention, they're related.
Can I have two words with the same name in different vocabs?
You probably don't want to design a set of vocabularies to have overlapping word names, but sometimes it comes up that you want to use two libraries that use the same word names. In this case, there are two resolution strategies. The simplest, if you only need one of the words which overlaps, is to put the one you want second in the order of the USING:
declaration. If you need both, or in more complicated overlap situations, you can use a qualified library import. In this case, you can enable qualified naming, and load a vocab called foo
with
QUALIFIED: foo
To access the word bar
in vocab foo
, use the name foo:bar
. When the same name is used in two vocabs, one vocab is usually put in the USING:
declaration and the other loaded with QUALIFIED:
.
This revision created on Fri, 18 Sep 2015 08:23:20 by AlexIlin (Rollback to 'Fix a typo.')