Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-10 Thread Shaping
Maybe the dsl aspect could be viewed as applying a layer of sugar to the
stack based workhorse.

 

Somewhat, but it is much more than sugar.  It is grease for the mind and
ironically traction too.  Shuffling is fragile until you are fluent.  Even
then it is work, and causes mistakes.  It is not a load I want to carry at
my DSL level.  I'll endure it as I must at the bottom, but I don't want to
work at the bottom when I'm immersed in thoughts of domain X.

 

  You could easily have 'adjectives' that accumulate into a variable,

 

Yes.  I have a noun-phrase grammar that uses mostly past participles (one
kind of adjective called a verbal) and adjectives proper as mutative (the U
in CRUD) and creative (the C in CRUD) modifiers.  We need a tree for this.
Free-form text, after three decades, looks silly.

 

 

 not on the stack, then a noun word that takes those options and does the
work.

 

The noun (if it is a class) is instantiated or (if it is an instance)
consumed or mutated.  In any of these cases, you have a noun phrase.

 

  This is how I accumulate attributes for the HTML elements, and it feels
like a dsl:

"Save" button <>submit
"org" id
<>form +content

button puts save into an attribute variable
<>submit uses (and clears) that variable, appends to the working collection
id puts "org" in the same place that button put things before
<>form uses the all-id variable to set attributes as it wraps what's on the
stack
+content puts it away somewhere.


This, I think, works fine for a dsl.  It also works fine if the 'attribute
value' is a field of an object on the stack, and the stack throughout this
is 
( page-assembly current-chunk xx -- page-assembly current-chunk )
or sometimes going down to 
( page-assembly current-chunk  -- page-assembly )

Using vocabularies, you could even keep an internal and an external version
of the word, where the stack one works faster, the other is the DSL.  

 

 

I need to be more familiar with all of the concepts and terms involved, to
produce a minimal set of well-factors nouns and modifiers.  Do you have a
complete example of a page creation-and-exercise scenario, against a
Factor-hosted web-server?  That would provide plenty of context.  The page
created/served/submitted can be small, like that form you showed me the
other day.

 

 

Shaping

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-10 Thread Shaping
Thanks for that Joe.  That helps a lot.

 

If I want general-to-particular reading order, must I define a parsing word
of my own?

 

Stack efficient order:

 

b negated 1/2a *  :> -b/2a

 

 

Context efficient order (general-to-particular perception and reasoning):

 

 -b/2a  <:  b negated a/2 *

 

(Yes, I made up my own long forms of recip, neg, and sq. )

 

That last form is like a traditional assignment statement.  How then do I
write the definition for

 

<:

 

?

 

Shaping

 

From: Joe Groff [mailto:arc...@gmail.com] 
Sent: 2010-November-09, 21:38
To: factor-talk@lists.sourceforge.net
Subject: Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations
about Factor

 

 

On Nov 9, 2010, at 2:08 PM, Shaping wrote:

 

 

I'm hungry for local variables, now, though this goes against much of the
basis of stack languages.  I want lexical forms I can read and understand
(parse with my mind, left-to-right, and down in a tree) to produce a known
result (not a best guess).  I don't want to remember a lot of stuff, because
human memory is fragile and ultimately limits all programmers.  I know that
we have a "locals" vocab of some kind, but don't know how to use it.  Is
anyone using locals a lot in Factor just for readability?  Can locals be
used efficiently for the machine, too?  How can locals be abused?

 

Locals are used all over the place, and suffer no performance penalty. Don't
worry about using them, or "going against the basis of stack languages."
Practicality beats purity. Often, after writing something out with locals,
it makes the concatenative approach clearer.

 

You can bind local variables by using the "::" definition form, which binds
the function's input values to lexical variables:

 

:: add ( x y -- z ) x y + ;

 

Within a :: definition, you can bind additional variables off the top of the
stack with the ":>" operator:

 

:: quadratic ( a b c -- x1 x2 )

2 a * recip :> 1/2a

b neg 1/2a * :> -b/2a

b sq 4 a c * * - sqrt 1/2a * :> disc/2a

-b/2a disc/2a +

-b/2a disc/2a - ;

 

-Joe

 

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-10 Thread Joe Groff
On Wed, Nov 10, 2010 at 4:51 PM, Shaping  wrote:
> If I want general-to-particular reading order, must I define a parsing word
> of my own?
>
>  -b/2a  <:  b negated a/2 *

Defining a <: operator with that exact syntax is not possible. For
one, in Factor, new symbol names can only be created as part of syntax
forms, and so must come after a syntax word of some sort. The new name
"-b/2a" in this case comes before the <: syntax word. The other
problem is that you need some way to indicate where the expression
whose value is being bound ends.

You could, however, define a form with explicit opening and closing
tokens, for example:

[set -b/2a := b negated a/2 * ]

The definition for "[set" would look something like this:

--
SYNTAX: [set
scan locals get parse-def ! scan a token and parse it as a locals binding
":=" expect ! scan a token and raise an error if it's not ":="
\ ] parse-until ! scan and parse objects until the "]" word is parsed
swap suffix! append! ;
! append first the expression body, then the local definition to
the parser accumulator
! as if it had appeared as "expression :> name"

:: foo ( x y -- z ) [set z := x y + ] z ;
--

-Joe

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-09 Thread Joe Groff

On Nov 9, 2010, at 2:08 PM, Shaping wrote:

>  
> I'm hungry for local variables, now, though this goes against much of the 
> basis of stack languages.  I want lexical forms I can read and understand 
> (parse with my mind, left-to-right, and down in a tree) to produce a known 
> result (not a best guess).  I don't want to remember a lot of stuff, because 
> human memory is fragile and ultimately limits all programmers.  I know that 
> we have a "locals" vocab of some kind, but don't know how to use it.  Is 
> anyone using locals a lot in Factor just for readability?  Can locals be used 
> efficiently for the machine, too?  How can locals be abused?

Locals are used all over the place, and suffer no performance penalty. Don't 
worry about using them, or "going against the basis of stack languages." 
Practicality beats purity. Often, after writing something out with locals, it 
makes the concatenative approach clearer.

You can bind local variables by using the "::" definition form, which binds the 
function's input values to lexical variables:

:: add ( x y -- z ) x y + ;

Within a :: definition, you can bind additional variables off the top of the 
stack with the ":>" operator:

:: quadratic ( a b c -- x1 x2 )
2 a * recip :> 1/2a
b neg 1/2a * :> -b/2a
b sq 4 a c * * - sqrt 1/2a * :> disc/2a
-b/2a disc/2a +
-b/2a disc/2a - ;

-Joe

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-09 Thread Jim mack
Maybe the dsl aspect could be viewed as applying a layer of sugar to the
stack based workhorse.  You could easily have 'adjectives' that accumulate
into a variable, not on the stack, then a noun word that takes those options
and does the work.  This is how I accumulate attributes for the HTML
elements, and it feels like a dsl:

"Save" button <>submit
"org" id
<>form +content

button puts save into an attribute variable
<>submit uses (and clears) that variable, appends to the working collection
id puts "org" in the same place that button put things before
<>form uses the all-id variable to set attributes as it wraps what's on the
stack
+content puts it away somewhere.

This, I think, works fine for a dsl.  It also works fine if the 'attribute
value' is a field of an object on the stack, and the stack throughout this
is
( page-assembly current-chunk xx -- page-assembly current-chunk )
or sometimes going down to
( page-assembly current-chunk  -- page-assembly )

Using vocabularies, you could even keep an internal and an external version
of the word, where the stack one works faster, the other is the DSL.
--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-09 Thread Jon Harper
Shaping,
have you read this page :
http://concatenative.org/wiki/view/Concatenative%20language ?

Jon

On Tue, Nov 9, 2010 at 10:44 AM, Shaping  wrote:
> Thanks Chris.  I'm working on this now.
>
> I managed to get the Browser looking really good with the stylesheet tweak
> that kenanb suggested.  Does anyone know how to change the font style and
> size in the Listener.
>
> Shaping
>
>
> -Original Message-
> From: Chris Double [mailto:chris.dou...@double.co.nz]
> Sent: 2010-November-09, 02:57
> To: factor-talk@lists.sourceforge.net
> Subject: Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations
> about Factor
>
> On Tue, Nov 9, 2010 at 9:38 PM, Shaping  wrote:
>>  I need to be able to write a parser in a
>> straightforward way (XStreams-style maybe) using a PEG (collection of BNF
>> productions) so that I can experiment efficiently with this idea.  Does
>> anyone have any experience with PEGs in Factor?
>
> Read the help for peg.ebnf. You can do this with the following in the
> listener:
>
>  "peg.ebnf" about
>
> Also these blog posts:
>
> http://www.bluishcoder.co.nz/2007/11/embedded-grammars-in-factor.html
> http://www.bluishcoder.co.nz/2008/04/factor-parsing-dsl.html
> http://www.bluishcoder.co.nz/2008/06/parsing-javascript-with-factor.html
>
> The code in them is slightly out of date but combined with the
> peg.ebnf help you should be able to get the idea. There are a few
> peg.ebnf usage examples for a JavaScript grammar, a PL0 grammar and an
> expression calculator in the Factor source.
>
> My PDF of articles might have more up to date code examples than the blog
> posts:
>
> http://www.bluishcoder.co.nz/factor-articles.pdf
>
> Chris.
> --
> http://www.bluishcoder.co.nz
>
> 
> --
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
> --
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-09 Thread Shaping
Thanks Chris.  I'm working on this now.

I managed to get the Browser looking really good with the stylesheet tweak
that kenanb suggested.  Does anyone know how to change the font style and
size in the Listener.

Shaping


-Original Message-
From: Chris Double [mailto:chris.dou...@double.co.nz] 
Sent: 2010-November-09, 02:57
To: factor-talk@lists.sourceforge.net
Subject: Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations
about Factor

On Tue, Nov 9, 2010 at 9:38 PM, Shaping  wrote:
>  I need to be able to write a parser in a
> straightforward way (XStreams-style maybe) using a PEG (collection of BNF
> productions) so that I can experiment efficiently with this idea.  Does
> anyone have any experience with PEGs in Factor?

Read the help for peg.ebnf. You can do this with the following in the
listener:

  "peg.ebnf" about

Also these blog posts:

http://www.bluishcoder.co.nz/2007/11/embedded-grammars-in-factor.html
http://www.bluishcoder.co.nz/2008/04/factor-parsing-dsl.html
http://www.bluishcoder.co.nz/2008/06/parsing-javascript-with-factor.html

The code in them is slightly out of date but combined with the
peg.ebnf help you should be able to get the idea. There are a few
peg.ebnf usage examples for a JavaScript grammar, a PL0 grammar and an
expression calculator in the Factor source.

My PDF of articles might have more up to date code examples than the blog
posts:

http://www.bluishcoder.co.nz/factor-articles.pdf

Chris.
-- 
http://www.bluishcoder.co.nz


--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-09 Thread Chris Double
On Tue, Nov 9, 2010 at 9:38 PM, Shaping  wrote:
>  I need to be able to write a parser in a
> straightforward way (XStreams-style maybe) using a PEG (collection of BNF
> productions) so that I can experiment efficiently with this idea.  Does
> anyone have any experience with PEGs in Factor?

Read the help for peg.ebnf. You can do this with the following in the listener:

  "peg.ebnf" about

Also these blog posts:

http://www.bluishcoder.co.nz/2007/11/embedded-grammars-in-factor.html
http://www.bluishcoder.co.nz/2008/04/factor-parsing-dsl.html
http://www.bluishcoder.co.nz/2008/06/parsing-javascript-with-factor.html

The code in them is slightly out of date but combined with the
peg.ebnf help you should be able to get the idea. There are a few
peg.ebnf usage examples for a JavaScript grammar, a PL0 grammar and an
expression calculator in the Factor source.

My PDF of articles might have more up to date code examples than the blog posts:

http://www.bluishcoder.co.nz/factor-articles.pdf

Chris.
-- 
http://www.bluishcoder.co.nz

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations about Factor

2010-11-09 Thread Shaping
In context, I thought I was mentioning it after I had counseled you to try a
factor code-compile-test cycle that wasn't perfectly what you desired to
just get going and have fun.  I just didn't want you to think I was trying
to shut down non-orthodox ideas - factor to me represents just the opposite.
Which I remember as a problem with forth - everyone did everything their own
way and reinvented many wheels, so it was too hard to get started for a
casual person.

 

I sense that I'm running in too many directions with Factor.  First, I need
to get a minimal regular Emacs config that just works for me most of the
time, like the one Slava is using in his video of Factor-with-Emacs, where
he build the simple GUI app and the TCP time server.  I'll do that tonight.

 

I appreciated the tutorial showing very cogently how easy coding and
co-testing are--in fact, how desirable testing-to-build is.  This is one of
Factor's best features.  A testing "harness" doesn't get any lighter.

 

I still have no significant stack discipline.   I don't practice much
code-writing yet.  I'm still playing with demos, and reading about the
language.  I'm especially interested in Joe's OpenGL shader demo, Furnace
and anything to do with composing and serving a blog (by this, I mean a very
rich hypermedia document created by one person and viewed by many), and
general-purpose PEG facilities, like those in VisualWorks XStreams
framework:

 

http://www.michaellucassmith.com/20100227%20Xtreams%20Primer.html
http://www.michaellucassmith.com/20100428%20Xtreams%20marshaler.html
http://www.michaellucassmith.com/20100502%20Xtream%20sharing.html)

 

I am concerned that there is little to no drive among those here fluent in
their Factor stack discipline/shuffle-patterns to build up and out of this
layer or grade of words (one close to the metal) into a pure domain-level
grammar (for any domain) free of shuffling or any need to be aware of it
while using the domain-level words to do practical work, like configuring
and starting a web server, for example.   This separation of the layers
seems difficult, and the bleed-through seems very common.   Become good
enough with your stack discipline, and soon you may not care much about
simpler more approachable DSLs.  That is my worry--that drive in this
direction varies inversely with Factor stack discipline.

 

I agree with prunedtree's recent comments, the gist of which is:  if you are
thinking about your domain logic and stack shuffling at the same time,
you've messed up.  I agree.  Getting this layering effect in the vocabs to
work without limiting machine-efficiency is my main goal.  I want the
optimizing compiler to be able to unswizzle the swizzles I create to ease
human reading and thinking.  I think some of this already happens, but do
not know how far it goes.

 

I'm noticing that Factor reading is not very efficient, because it taxes
human memory.  I know that I will be more fluent eventually, but, for now:
I have the places on the stack to watch and to keep in order in my mind, the
types of the entities in those slots to watch (in my mind because they are
not often named), and the before/after stack state to remember or watch in
the status bar, all in order to read Factor fluently, one word to the next.
That process is heavy until stack discipline is firm and lots of memories of
stack-effects have been cemented.  I'm not sure that is a good basic
constraint to have in a language.  But I'm not convince that long
self-documenting words (with extra bits about before/after stack state) are
the answer, either.  

 

I'm hungry for local variables, now, though this goes against much of the
basis of stack languages.  I want lexical forms I can read and understand
(parse with my mind, left-to-right, and down in a tree) to produce a known
result (not a best guess).  I don't want to remember a lot of stuff, because
human memory is fragile and ultimately limits all programmers.  I know that
we have a "locals" vocab of some kind, but don't know how to use it.  Is
anyone using locals a lot in Factor just for readability?  Can locals be
used efficiently for the machine, too?  How can locals be abused?

 

I like explicitly clear code with a semantic focus on the values that are
being produced, what they are named and where they live (stack, locals).
Transitive verbs, so popular in all programming language, whether used in
words or methods or functions or procedures or whatever are weak to useless
at communicating what you are getting, where it's coming from and where it's
landing.  Verbs/action concepts in programming languages provide excellent
background context for the values being computed during those verb/action
intervals, but code that emphasizes them strongly without strong focus on
values computed, tends to be noisy and hard to
read/understand/remember/discuss.  I want to work this focus on values into
a basic CRUD DSL in Factor.  I need to be able to write a parser in a
straightforward wa