Doug Nichols | 2 Jun 2008 19:11
Picon

linux ppc build problem

I built factor on an old G3 ibook that runs Ubuntu Gutsy.  When I started factor from the command line, I noticed a couple of issues:
 
1.  There were several buttons at the top of the gui that lacked any text.  They appear to have functionality but no text on them identifying what they do.
2.  When I type in the gui, the current character under the cursor is always wrong.  For example, if I type a 1, it displays as something else, until I type a space after it, at which time it becomes a 1.
 
Then I opened up the cookbook and ran into another issue:  following the basic syntax cookbook, I typed 10 sq 5 - .
Instead of 95, I got 99 as the result.  Just for fun, I tried reversing the numbers and typed 5 sq 10 - .  This time I got -99
 
Any suggestions would be appreciated.
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Doug Coleman | 2 Jun 2008 21:56
Picon

Re: linux ppc build problem

Try using the tty listener:
./factor -run=listener

I have never had arithmetic calculations mess up like that.  Can you  
narrow down the problem if it's broken in the tty?

Doug

On Jun 2, 2008, at 12:11 PM, "Doug Nichols" <d.n.nola@...> wrote:

> I built factor on an old G3 ibook that runs Ubuntu Gutsy.  When I  
> started factor from the command line, I noticed a couple of issues:
>
> 1.  There were several buttons at the top of the gui that lacked any  
> text.  They appear to have functionality but no text on them  
> identifying what they do.
> 2.  When I type in the gui, the current character under the cursor  
> is always wrong.  For example, if I type a 1, it displays as  
> something else, until I type a space after it, at which time it  
> becomes a 1.
>
> Then I opened up the cookbook and ran into another issue:  following  
> the basic syntax cookbook, I typed 10 sq 5 - .
> Instead of 95, I got 99 as the result.  Just for fun, I tried  
> reversing the numbers and typed 5 sq 10 - .  This time I got -99
>
> Any suggestions would be appreciated.
>
> --- 
> ----------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@...
> https://lists.sourceforge.net/lists/listinfo/factor-talk

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Doug Nichols | 3 Jun 2008 02:12
Picon

Re: linux ppc build problem

It seems to be an issue of improper display rather than incorrect calculation.  The integer arithmetic I tried in the listener worked fine.  I played with the gui a little more and noticed that for two-digit numbers, it always showed them as duplications of the first digit, i.e., 100 5 - . produces 99, 100 25 - . produces 77, etc.  For three-digit numbers, the first two look correct but the last one is a copy of the middle digit, i.e., 100 1 + . yields 100, 100 20 + . yields 122, etc.

But the listener does seem to be working for me.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Stefan Scholl | 4 Jun 2008 12:12
Picon
Favicon
Gravatar

Re: factorforge.org

Don't forget to "register" it on
http://en.wikipedia.org/wiki/Comparison_of_free_software_hosting_facilities#Specific_requirements_or_preferences

--

-- 
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Slava Pestov | 7 Jun 2008 21:00

Stack effect inference

Hi all,

For a while now Factor has required that the stack effect be declared  
on recursive words. Non-recursive words did not require a declaration,  
but it was considered good style to add one except for the most  
trivial words (such as those pushing constants on the stack).

Well, the problem is that I recently realized any word can technically  
become recursive, _except_ those that push constants on the stack! So  
what we have now is unsound.

Consider this scenario:

You're working at a large enterprisey firm on a project with lots of  
developers ;-)

Developer A writes the following code:

GENERIC: a ( x -- y )

GENERIC: c ( x -- y )

Developer B writes the following code:

: b ... a ... ; ! no stack effect declaration -- but it's not recursive!

M: foo c ... b ... ;

Developer C writes this:

M: bar a ... c ... ;

Wham, suddenly 'b' is recursive, because we have a cycle in the  
control flow graph: a -> c -> b -> a, which didn't exist before! But  
developer C doesn't care about the word 'b', they may not know it  
exists even, but they just broke it.

This scenario is not contrieved; it comes up in extra/ from time to  
time. Someone will add some code which defines a bunch of methods,  
then suddenly the compiler starts complaining about some totally  
random word being recursive and needing a stack effect, such as this  
word from calendar.format:

: YYYY year>> write-0000 ;

Surely it doesn't look recursive, but there is some path through the  
call graph where write-0000 calls write, which calls some low-level  
Unix I/O code, which somehow calls back into the calendar code...

To make matters worse, it doesn't _always_ complain about a word  
needing a stack effect declaration. Sometimes things work out just  
fine and it gets along without hitting the code path where it needs  
the declaration to be there. So what we have here is that some guy  
makes an innocent-looking change to the code, and at some undetermined  
point in the future, a totally unrelated word may stop compiling.

The technical term for languages with such features is "toy  
language" :-)

Since my plan is to use Factor to take over the world and get  
disgustingly rich, this is not an acceptable state of affairs. There  
are two solutions:

1) Revive the old stack effect inference algorithm which did not  
require annotations at all.

2) Require stack effect declarations on all words except for the most  
trivial ones which only push literals on the stack

I don't want to do #1 because the old algorithm was more complex, both  
in terms of code and run time. So that leaves us with #2. I don't mind  
having to annotate more words, what do you guys think?

Slava

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Slava Pestov | 9 Jun 2008 06:20

replace-patterns in cpu.8080.emulator

Hi all,

Here is some code from cpu.8080.emulator:

SYMBOL: $1
SYMBOL: $2
SYMBOL: $3
SYMBOL: $4

: replace-patterns ( vector tree -- tree )
   #! Copy the tree, replacing each occurence of
   #! $1, $2, etc with the relevant item from the
   #! given index.
   dup quotation? over [ ] = not and [ ! vector tree
     dup first swap rest ! vector car cdr
     >r dupd replace-patterns ! vector v R: cdr
     swap r> replace-patterns >r 1quotation r> append
   ] [ ! vector value
     dup $1 = [ drop 0 over nth  ] when
     dup $2 = [ drop 1 over nth  ] when
     dup $3 = [ drop 2 over nth  ] when
     dup $4 = [ drop 3 over nth  ] when
     nip
   ] if ;

This code was written a while ago, before we had some of the  
abstractions we do now.

Here is a new version:

SYMBOLS: $1 $2 $3 $4 ;

: replace-patterns ( vector tree -- tree )
   [
     {
       { $1 [ first ] }
       { $2 [ second ] }
       { $3 [ third ] }
       { $4 [ fourth ] }
       [ nip ]
     } case
   ] with deep-map ;

Slava

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
janko metelko | 9 Jun 2008 19:17
Picon

Re: Stack effect inference

I vote for #2, I probably need/want stack effect declarations even more than the compiler when I look at code.

But, I vote for
2b) Require stack effect declarations on all words

On Sat, Jun 7, 2008 at 12:00 PM, Slava Pestov <slava-ZiOttN0IXrP2JYTphGNI2Q@public.gmane.org> wrote:
Hi all,

For a while now Factor has required that the stack effect be declared
on recursive words. Non-recursive words did not require a declaration,
but it was considered good style to add one except for the most
trivial words (such as those pushing constants on the stack).

Well, the problem is that I recently realized any word can technically
become recursive, _except_ those that push constants on the stack! So
what we have now is unsound.

Consider this scenario:

You're working at a large enterprisey firm on a project with lots of
developers ;-)

Developer A writes the following code:

GENERIC: a ( x -- y )

GENERIC: c ( x -- y )

Developer B writes the following code:

: b ... a ... ; ! no stack effect declaration -- but it's not recursive!

M: foo c ... b ... ;

Developer C writes this:

M: bar a ... c ... ;

Wham, suddenly 'b' is recursive, because we have a cycle in the
control flow graph: a -> c -> b -> a, which didn't exist before! But
developer C doesn't care about the word 'b', they may not know it
exists even, but they just broke it.

This scenario is not contrieved; it comes up in extra/ from time to
time. Someone will add some code which defines a bunch of methods,
then suddenly the compiler starts complaining about some totally
random word being recursive and needing a stack effect, such as this
word from calendar.format:

: YYYY year>> write-0000 ;

Surely it doesn't look recursive, but there is some path through the
call graph where write-0000 calls write, which calls some low-level
Unix I/O code, which somehow calls back into the calendar code...

To make matters worse, it doesn't _always_ complain about a word
needing a stack effect declaration. Sometimes things work out just
fine and it gets along without hitting the code path where it needs
the declaration to be there. So what we have here is that some guy
makes an innocent-looking change to the code, and at some undetermined
point in the future, a totally unrelated word may stop compiling.

The technical term for languages with such features is "toy
language" :-)

Since my plan is to use Factor to take over the world and get
disgustingly rich, this is not an acceptable state of affairs. There
are two solutions:

1) Revive the old stack effect inference algorithm which did not
require annotations at all.

2) Require stack effect declarations on all words except for the most
trivial ones which only push literals on the stack

I don't want to do #1 because the old algorithm was more complex, both
in terms of code and run time. So that leaves us with #2. I don't mind
having to annotate more words, what do you guys think?

Slava

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Factor-talk mailing list
Factor-talk-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/factor-talk

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Joe Groff | 9 Jun 2008 20:29
Picon
Gravatar

Re: Stack effect inference

> Since my plan is to use Factor to take over the world and get
> disgustingly rich, this is not an acceptable state of affairs. There
> are two solutions:
>
> 1) Revive the old stack effect inference algorithm which did not
> require annotations at all.
>
> 2) Require stack effect declarations on all words except for the most
> trivial ones which only push literals on the stack
>
> I don't want to do #1 because the old algorithm was more complex, both
> in terms of code and run time. So that leaves us with #2. I don't mind
> having to annotate more words, what do you guys think?

It might make sense to require all definitions to have a stack effect,  
and have a shorthand parsing word for defining constant words. The  
CONST: word could ensure that the definition consists of nothing but  
literals and other const words, automatically apply "inline" and any  
other optimizer annotations that make sense, and maybe even figure out  
the types of the literals and annotate the stack effect with them. For  
example:

CONST: FOO_BAR_BAS "foo" "bar" "bas" ;

could expand out to:

: FOO_BAR_BAS ( -- |string |string |string )
     "foo" "bar" "bas" ; inline const ! etc.

-Joe

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Eduardo Cavazos | 10 Jun 2008 00:04
Picon

Short-circuiting combinators which return their value

Hello,

In combinators.lib, we have &&, ||, and some arity variants. However, they 
only return 't' or 'f'. We're interested in versions which return non-f 
results. In the case of '||' it would return the first non-f result. In the 
case of '&&' it would return the last result if all the results were non-f.

If you perform a manual expansion of expressions which you'd pass to && 
and ||, a pattern arises. I think this macro captures the 0 arity case:

: 0||-rewrite ( quots -- quot )
  dup empty?
    [ drop [ ] ]
    [ unclip swap 0||-rewrite '[ drop  <at>  dup [ ] [  <at>  ] if ] ]
  if ;

MACRO: 0|| ( quots -- quot ) 0||-rewrite f prefix ;

	This is 1 arity case:

: 1||-rewrite ( quots -- quot )
  dup empty?
    [ drop [ nip ] ]
    [ unclip swap 1||-rewrite '[ drop dup  <at>  dup [ nip ] [  <at>  ] if ] ]
  if ;

MACRO: 1|| ( quots -- quot ) 1||-rewrite f prefix ;

	And finally the 2 arity case:

: 2||-rewrite ( quots -- quot )
  dup empty?
    [ drop [ 2nip ] ]
    [ unclip swap 2||-rewrite '[ drop 2dup  <at>  dup [ 2nip ] [  <at>  ] if ] ]
  if ;

MACRO: 2|| ( quots -- quot ) 2||-rewrite f prefix ;

Fry really helped here. I'm the syntax rebel/separatist around here. I'd been 
experimenting with a syntax I call "auto fry" whereby you don't have to 
single-quot a quotation in order to fry it. If a quotation contains fry 
directives, it's fried. I really like this but this in this application it 
didn't work. I was using auto-fry instead of the explicit fry above. The 
probem is, the quotation I intend to fry is actually in another quotation. 
The inner directives cause the outer quotation to fry; not the desired 
result...

Ed

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Eduardo Cavazos | 10 Jun 2008 01:53
Picon

Non-recursive versions of the short-circuiting combinators

Hello,

Here are non-recursive versions of 0||, 1||, 0&&, and 1&&. They expand 
into 'cond':

MACRO: 0|| ( quots -- quot )
  [ '[ drop  <at>  dup ] [ ] {2} ] map
  { [ drop t ] [ f ] }        suffix
  '[ f , cond ] ;

MACRO: 1|| ( quots -- quot )
  [ '[ drop dup  <at>  dup ] [ nip ] {2} ] map
  { [ drop drop t ] [ f ] }           suffix
  '[ f , cond ] ;

MACRO: 0&& ( quots -- quot )
  [ '[ drop  <at>  dup not ] [ drop f ] {2} ] map
  { [ t ] [ ] }                          suffix
  '[ f , cond ] ;

MACRO: 1&& ( quots -- quot )
  [ '[ drop dup  <at>  dup not ] [ drop drop f ] {2} ] map
  { [ t ] [ nip ] }                               suffix
  '[ f , cond ] ;

Ed

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

Gmane