Slava Pestov | 7 Sep 01:57

Retain stack, dip, compose, fry, locals

Hi all,

Continuing one of the lines of thought Ed laid out in his post, it is
in fact true that all of the above are equivalent in some sense.

Right now >r/r> are primitive, and we implement dip, compose, fry and
locals in terms of them.

What if dip was primitive, but not >r/r> ? We could add them as
parse-time syntax sugar:

DEFER: r>
: >r \ r> parse-until >quotation parsed \ dip parsed ; parsing

What if we had compose and curry primitives, but not dip or >r/r> ? We
can implement dip with compose/curry, and >r/r> as above:

: dip ( a quot -- a ) swap [ ] curry compose call ; inline

What if we had fry, but not compose and curry? Then we can implement
curry, compose and dip with fry:

: curry '[ , @ ] ; inline
: compose '[ @ @ ] ; inline
: dip swap '[ @ , ] ; inline

What if we had locals, but not compose and curry and dip?

:: curry ( a quot -- curry ) [ a quot call ] ; inline
:: compose ( quot1 quot2 -- compose ) [ quot1 call quot2 call ] ; inline
(Continue reading)

Eduardo Cavazos | 6 Sep 23:15

Binding from the stack

Hello,

I've been programming in Factor for a few years now. I guess I'm a slow 
learner because I've just now had a certain eureka moment this morning. I 
even think folks have mentioned this to me before but it didn't click until 
today. The idea I finally groked:

	Locals is an abstraction of the retain stack

Maybe some of you are familiar with User RPL, the programming language of the 
HP48. Folks write some pretty complex stuff in RPL. Guess what's missing from 
User RPL? A retain stack. But what *do* they have? Locals. They use this 
syntax:

	-> a b << a b + >>

In RPL, their "quotations" are delimited using '<<' and '>>'. The above means 
bind 'a' and 'b' to values from the stack and execute the program. They also 
support "algebraic" expressions so the above could be written as:

	-> a b 'a+b'

Now I'm going to throw out a claim:

	Every piece of code which uses '>r' and 'r>' could be more clearly written
	using locals.

I think this is an important fact because from a teachers perspective, it 
means you only need to show a student locals and they don't need to learn 
about the retain stack at all.
(Continue reading)

Doug Coleman | 4 Sep 09:02

Documentation tool update

Hi,

I wrote a blog entry linked from http://factorcode.org about a new  
documentation tool in tools.scaffold.  As described in the blog, it's  
not much use for vocabularies that already have help files, so I have  
added a couple of utility words.

USE: tools.scaffold

( scratchpad ) "kernel" scaffold-undocumented
HELP: callstack>array
{ $description } ;

HELP: loop
{ $values
      { "pred" null } }
{ $description } ;

Edit documentation: P" resource:core/kernel/kernel-docs.factor"

( scratchpad ) \ loop help.
HELP: loop
{ $values
      { "pred" null } }
{ $description } ;

Edit documentation: P" resource:core/kernel/kernel-docs.factor"

You can copy and paste the undocumented words into the docs files by  
following the link.  I hope this makes it super-easy to document the  
(Continue reading)

Slava Pestov | 3 Sep 11:04

Faster loading of sequence implementations

Hi all,

For a long time, loading a vocabulary which defined a new type of
sequence would take forever due to recompilation. With the new
front-end and optimizer, not any more:

( scratchpad ) [ "bit-vectors" require ] time
Loading resource:basis/bit-vectors/bit-vectors.factor
Loading resource:basis/bit-vectors/bit-vectors-docs.factor
:warnings - print 1 semantic warnings.
==== RUNNING TIME

6465 ms

==== GARBAGE COLLECTION

                         Nursery  Aging    Tenured
GC count:                299      45       2
Cumulative GC time (ms): 274      634      631
Longest GC pause (ms):   10       20       419
Average GC pause (ms):   0        14       315
Objects copied:          649567   1345374  1787920
Bytes copied:            32764992 71420704 99889592

Total GC time (ms):      1539
Cards scanned:           275529
Decks scanned:           9426
Code heap literal scans: 33

( scratchpad ) [ "float-arrays" require ] time
(Continue reading)

Eduardo Cavazos | 3 Sep 09:34

New vocabulary browser

Hello,

There's a new vocabulary browser in development. Here's some instructions for 
trying it out.

It's in the latest git so make sure you have that.

It's in the 'unfinished' vocabulary root. So make sure it's in your roots 
list:

	"resource:unfinished" vocab-roots get push
	save

Load it:

	USE: vocab-browser

Then do:

	"vocab-indices" help

and click on one of the indices. Beware of the "All" and "Unloaded" indices as 
they can take a while to load.

When you're looking at a vocabulary index, if the vocabulary has a '*' next to 
the name, it means it's not loaded yet. If you click on it, it'll get loaded.

Go forth and explore the Factor labyrinth.

Ed
(Continue reading)

Phil Dawes | 1 Sep 15:07

asm intrinsics for speed

Hi Slava,

I'm building (what amounts to) an olap database engine in factor, and 
part of that involves linear searching mmapped files. Basically the 
faster I can do linear searching operations, the less I need to use 
sorted indexes and the more data I can fit into memory (esp with 
compression). I've currently got a bunch of C code doing searches, but 
ideally I'd like to not rely on a separate C dll in the released code or 
require people to have the gcc tool chain to compile it.

I decided to experiment with using asm intrinsics to implement the tight 
loops, and took 'count' as a simple testcase. I'm searching a 48M file 
of 32bit integers.

By comparison some C code (minus the mmaping stuff):

int count_items(int *from,int *to,int item) {
   int count = 0;
   while(from != to){
     if(*from == item) count++;
     from ++;
   }
   return count;
}

Which when compiled with -O3 takes about 80ms to search the file on a 
processor locked at 800MHZ with the filebuffers running warm. The best I 
could do with factor in this setup was a few seconds (which I think is 
still pretty good).

(Continue reading)

nii amon dsane | 1 Sep 11:46

Factor on Mac OS X Tiger

If you having problems building factor for OS X Tiger, you can use these steps: they worked for me.


1. get git:


2. compile and install it:

tar xvfz git-1.5.6.4/tar.bz2
./configure
make
make install

3. Download factor install file:


4. Rename it as factor.sh

5. make it executable
chmod u=rwx factor.sh

6. kick off install
./factor.sh install

7. This will take some time so be patient.

8. after installation, open factor in downloaded source folder:
open Factor.app from command line or double-click on the Factor.app in the directory

Nii Amon 
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Eduardo Cavazos | 1 Sep 02:14

RESOLVE: and QUALIFIED:

Slava wrote:

> Let me again propose the feature where if you have a:foo and b:foo, then
> USING: a b ; foo, you get a parse time error about ambiguity in the search
> order.

We currently have ways to address the problem. For one, there is no ambiguity 
because the USING: order determines which one is referred to. It's not 
exactly correct to call this an ambiguity problem.

What happens if the user of 'a' and 'b' decides to deal with the problem using 
the tools provided by qualified. Will they be allowed to? Will they be forced 
to use RESOLVE: instead even if QUALIFIED: does the job?

Perhaps your proposal should be viewed as two separate items.

One: throw a parse time error if more than one used vocabulary exports the 
same name which is in turn used by the using vocabulary.

Two: A 'RESOLVE:' form which can solve the above issue. This would be in 
addition to other tools which are available to fix the problem.

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Eduardo Cavazos | 1 Sep 02:08

RESOLVE: for unused words

Slava wrote:

> Let me again propose the feature where if you have a:foo and b:foo, then
> USING: a b ; foo, you get a parse time error about ambiguity in the search
> order.

What happens if the vocabulary using 'a' and 'b' doesn't refer to 'foo'? Will 
the error occur?

That would be mighty annoying if I'm using some vocabularies and have to 
RESOLVE: words that I don't even use.

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Eduardo Cavazos | 1 Sep 01:16

RESOLVE: form

Moving this to 'factor-talk' so others can chime in. You give a good enough 
description below so that others can catch up.

Slava wrote:

> We figured this out. Doug added a 'second' word to calendar which shadowed
> sequences:second in ui.gestures.
>
> This took me 5 minutes to bootstrap and another 5 to debug. Adding the time
> Doug spent on this, we have about half an hour of lost work between the two
> of us.
>
> Let me again propose the feature where if you have a:foo and b:foo, then
> USING: a b ; foo, you get a parse time error about ambiguity in the search
> order. A RESOLVE: parsing word could be used to specify which one you want,
> so adding RESOLVE: a foo or RESOLVE: b foo would solve the parse error. If
> this had been a parse error, Doug could've bootstrapped and Factor would've
> immediately indicated that something was wrong. He would see a message much
> like the following:
>
> The word "second" is defined in more than one vocabulary in the search path
> but no RESOLVE: form was given.
>
> Restarts:
>
> 1: Use calendar
> 2: Use sequences
>
> This would have enabled him to fix the issue in a matter of seconds and
> saved us both time.

OK. This is a nice real world example of the problem. But when you say "Let me 
again propose the feature..." I'm taking that to mean "propose for further 
analysis" and not "propose for immediate inclusion". Let's think about how 
this would impact things.

Let's say vocabularies X Y Z use vocabulary A. I edit A. I refresh-all. Let's 
suppose that 'refresh-all' has the proposed behaviour whereby it refreshes X 
Y and Z since they depend on A (I believe you mentioned that this is a 
planned feature). Alright, let's say the above problem scenario occurs; a new 
word in A shadows a word from a vocabulary that X Y and Z use. When I do my 
refresh-all I'm going to get error messages about how the change is causing 
problems in X Y and Z.

So this is going to lead to a situation where I am constrained about how I 
name things in my vocabulary based on how *others* use it. The whole freedom 
to name is now impeded a bit.

Moreover, the above notifications about how I'm impacting other vocabularies 
*only* happen if I happen to have X, Y, and Z loaded. What about all the 
stuff in the CFAN (CPAN for factor...)? I'm not going to know I'm impacting 
any of that. What about stuff that's in 'extra' that I haven't bothered to 
load?

I also have a request. Let's do an analysis of the current code base. Let's 
suppose RESOLVE: were implemented. How many vocabularies would be impacted?

Here's something else to consider. Your complaint is that the shadowing 
occured but you weren't notified about it. It's quite possible that when such 
shadowing occurs, you'll get compile time errors because of a mismatched 
stack effect. Did you not see such errors after Doug added 'second' to 
calendar? This sort of detection is only going to go up as folks use types in 
their effects more often and the compiler gets better at detecting 
inconsistencies.

Maybe it's a good and necessary idea. I'm just trying to think about it.

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Joe Groff | 31 Aug 19:50

<CFNumber> still references c-types at runtime in deployed image. Not sure why

I was trying to deploy an image, and the resulting app is bombing out  
with a "no-c-type" exception inside a call to <CFNumber>. Now it's no  
big deal to switch on "deploy-c-types?", but looking at the definition  
of <CFNumber> in core-foundation, it seems like it shouldn't need the  
c-types at runtime:

GENERIC: <CFNumber> ( number -- alien )
M: integer <CFNumber>
     [ f kCFNumberLongLongType ] dip <longlong> CFNumberCreate ;
M: float <CFNumber>
     [ f kCFNumberDoubleType ] dip <double> CFNumberCreate ;
M: t <CFNumber>
     drop f kCFNumberIntType 1 <int> CFNumberCreate ;
M: f <CFNumber>
     drop f kCFNumberIntType 0 <int> CFNumberCreate ;

Is there something here I'm missing that prevents the optimizing  
compiler picking out the <c-object> calls? Calling infer on each  
method definition gives the expected (( object -- object )), and "core- 
foundation" reload doesn't emit any warnings or errors.

-Joe

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane