Hi Dan,

I have some random observations.

This word does not compile because of unbalanced branches:

: alist-set ( value key alist -- )
     3dup alist-find [
         1 swap set-nth 3drop
     ] [
         >r swap 2array r> push
     ] if ;

In case you missed the compile error; here's a useful trick. Call   
print-warnings off  before loading the libs/xml module, then only  
compile errors will be shown. Or, use the UI, where the messages tool  
separates the two.

Indeed the implementation is totally incorrect, and it has no unit  
tests. Please write unit tests. Here is a correct version:

: alist-set ( value key alist -- )
     2dup alist-find [
         2nip 1 swap set-nth
     ] [
         >r swap 2array r> push
     ] if* ;

Can you add this new version, and some unit tests.

Also some word renamings I'd like you to make:

- in XML, attributes are called attributes, not properties. Change  
the tag-props slot to tag-attrs
- alist-find --> find-attr
- alist-get  --> get-attr
- alist-set  --> set-attr
- prop-name  --> get-tag-attr
- prop-name-tag --> tag-attr-named
- get-name-tag --> tag-named
- get-name-tags --> tags-named
- find-name-tag --> child-named
- find-name-tags --> children-named

It would be nice if instead of separate words for strings and names,  
you had generic words which were polymorphic over strings and names.

In state-parser.factor, you have code like this:

: get-char ( -- char ) spot get first ;
: set-char ( char -- ) 0 spot get set-nth ;
: get-line ( -- line ) spot get second ;
: set-line ( line -- ) 1 spot get set-nth ;
: get-column ( -- column ) spot get third ;
: set-column ( column -- ) 2 spot get set-nth ;
: get-next ( -- char ) spot get fourth ;
: set-next ( char -- ) 3 spot get set-nth ;

This is a re-invention of tuples. What's wrong with:

TUPLE: spot char line column next ;

: get-char ( -- char ) spot get spot-char ;
: set-char ( char -- ) spot get set-spot-char ;
: get-line ( -- line ) spot get spot-line ;
... etc

Slava

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to