The easiest way if your already a git user is git-svnDerek_Stewart wrote: I also have vonvert the SV book "Version Control with Subversion" to epub, to understand SVN...

The easiest way if your already a git user is git-svnDerek_Stewart wrote: I also have vonvert the SV book "Version Control with Subversion" to epub, to understand SVN...
Seconded! We did this at a customer who had a corporate policy of using SVN but our team wanted to use git.XorA wrote:The easiest way if your already a git user is git-svnDerek_Stewart wrote: I also have vonvert the SV book "Version Control with Subversion" to epub, to understand SVN...
Code: Select all
: NEW ." NOOP for NEW in FORTH context" ;
: A_CLASS , ;
: AN_INSTANCE @ , ;
: METHOD DUP @ EXECUTE ;
: INSTANCE CREATE AN_INSTANCE DOES> METHOD ;
: CLASS CREATE A_CLASS DOES> INSTANCE ;
END_FILE
Code: Select all
VOCABULARY CAT> ' CAT> CLASS CAT
CAT> DEFINITIONS
: NEW DROP CR ." Instanciating a CAT" ;
: SPEAK ." MEEEEOOOW !" CR ;
CAT FELIX FELIX NEW
FELIX SPEAK
CAT> VOCABULARY TOMCAT> ' TOMCAT> CLASS TOMCAT
TOMCAT> DEFINITIONS
: HEY ." I am a TOMCAT" CR ;
TOMCAT FRITZ FRITZ NEW
FRITZ SPEAK
FRITZ HEY
END_FILE
Code: Select all
VOCABULARY VECTOR> ' VECTOR> CLASS VECTOR
VECTOR> DEFINITIONS
VARIABLE SIZE
CR .( SIZE holds the size of the last VECTOR named )
VARIABLE SAME
CR .( SAME is a boolean TRUE if SIZE equals size )
: SAME? ( size --- ) DUP SIZE @ = SAME ! SIZE ! ;
CR .( SAME? is a function to update SIZE and SAME )
: SIZE! ( size --- ) SIZE ! ;
: SIZE@ ( --- size ) SIZE @ ;
: NEW ( size --- ) DUP SIZE! DUP , 2* ALLOT ;
: ! ( Nx16bit#,V --- ) DROP CR ." pop and store Nx16bit# into V" ;
: @ ( V --- N1..NK,K ) DROP CR ." push Nx16bit# from V onto the data stack" ;
: + DROP CR ." add 2 Nx16bit# of the data stack, result : Nx16bit#" ;
: - DROP CR ." substract 2 Nx16bit# of the data stack, result : Nx16bit#" ;
: K* ( Nx16bit#,k --- Nx16bit# ) DROP CR ." product of a VECTOR by a scalar k" ;
: S* ( 2 Nx16bit# --- k ) DROP CR ." k is the scalar product of 2 VECTORs" ;
VECTOR> VOCABULARY 3DVECTOR> ' 3DVECTOR> CLASS 3DVECTOR
3DVECTOR> DEFINITIONS
: NEW 3 NEW CR ." uses NEW of the parent class with size = 3" ;
: * ( 2 3x16bit# --- 3x16bit# ) CR ." vector product of two 3DVECTORs" ;
: M* ( 3 3x16bit# --- m ) CR ." mixed vector product of three 3DVECTORs" ;
END_FILE
Code: Select all
CR .( Three words needed to complement SupperFORTH )
CR .( mixed multiplication : two 16 bits operands 32 bits result )
: M* ( n1,n2 --- d ) 1 OVER 0< IF NEGATE SWAP NEGATE ELSE SWAP THEN >R
OVER 0< IF NEGATE SWAP NEGATE ELSE SWAP THEN R>
UM* ROT 0< IF DNEGATE THEN ;
CR .( mixed division 32 bits divident 16 bits divisor 16 bits result )
: M/ ( d1,n2 --- n ) 1 OVER 0< IF NEGATE SWAP NEGATE ELSE SWAP THEN >R
OVER 0< IF NEGATE ROT ROT DNEGATE ELSE ROT ROT THEN R>
UM/MOD SWAP DROP SWAP 0< IF 1+ NEGATE THEN ;
CR .( mixed square root : 32 bits operand 16 bits result )
: MSQRT ( d --- n,p | d = p*p + n ) 2DUP OR IF -32768 BEGIN
DUP >R DUP M* 2OVER D- R@ UM/MOD SWAP DROP 2/ R> SWAP
?DUP WHILE - REPEAT 1- >R R@ R@ M* D- DROP R> THEN ;
CR .( Words to implement object oriented programming in FORTH )
: NEW ; ( NOOP word for NEW in FORTH context )
: A_CLASS , ;
: AN_INSTANCE @ , ;
: METHOD DUP @ EXECUTE ;
: INSTANCE CREATE AN_INSTANCE DOES> METHOD ;
: CLASS CREATE A_CLASS DOES> INSTANCE ;
CR .( Example CLASS of 3D vectors )
CR .( 3D> is the VOCABULARY of the METHODs )
CR .( 3D is the name of the CLASS )
VOCABULARY 3D> ' 3D> CLASS 3D
3D> DEFINITIONS
CR .( After creating these two words, let's implement the METHODs )
CR .( first : NEW for intalling an INSTANCE - for 3D, just ALLOT 6 bytes )
: NEW 6 ALLOT DROP ;
CR .( some unary methods : ! and @ like for 16 bits scalars and X Y Z )
: ! ( x,y,z,V --- ) DUP >R 6 + ! R@ 4 + ! R> 2+ ! ;
: X ( V --- x ) 2+ @ ;
: Y ( V --- y ) 4 + @ ;
: Z ( V --- z ) 6 + @ ;
: @ ( V --- x,y,z ) 2+ DUP @ OVER 2+ @ ROT 4 + @ ;
CR .( some binary methods : )
CR .( add two vectors : overloads scalar addition )
: + ( V,V --- V ) OVER >R @ 3 ROLL @ 3 ROLL + >R ROT + >R + R> R> R@ ! R> ;
CR .( substract two vectors : overloads scalar substraction )
: - ( V,V --- V ) OVER >R @ 3 ROLL @ 3 ROLL - >R ROT - >R SWAP - R> R> R@ ! R> ;
CR .( scaled scalar product of two vectors )
: // ( V,V,s --- scalar prpduct / s ) >R SWAP @ 3 ROLL @
3 ROLL M* 2SWAP 4 ROLL M* ROT 5 ROLL M* D+ D+ R> M/ ;
CR .( scaled vector product of two vectors : overloads */ for scalars )
: */ ( V,V,s --- vector product / s ) 2 PICK >R >R SWAP @ 3 ROLL @
4 PICK OVER M* 3 PICK 6 PICK M* D- R@ M/
4 ROLL 4 PICK M* 3 ROLL 7 PICK M* D- R@ M/
5 ROLL 3 ROLL M* 4 ROLL 5 ROLL M* D- R> M/ R@ ! R> ;
CR .( modulus of a vector )
: || @ DUP M* ROT DUP M* D+ ROT DUP M* D+ MSQRT SWAP DROP ;
CR END_FILE
Code: Select all
CR .( Three words needed to complement SupperFORTH )
CR .( mixed multiplication : two 16 bits operands 32 bits result )
: M* ( n1,n2 --- d ) 1 OVER 0< IF NEGATE SWAP NEGATE ELSE SWAP THEN >R
OVER 0< IF NEGATE SWAP NEGATE ELSE SWAP THEN R>
UM* ROT 0< IF DNEGATE THEN ;
CR .( mixed division 32 bits divident 16 bits divisor 16 bits result )
: M/ ( d1,n2 --- n ) 1 OVER 0< IF NEGATE SWAP NEGATE ELSE SWAP THEN >R
OVER 0< IF NEGATE ROT ROT DNEGATE ELSE ROT ROT THEN R>
UM/MOD SWAP DROP SWAP 0< IF 1+ NEGATE THEN ;
CR .( mixed square root : 32 bits operand 16 bits result )
: MSQRT ( d --- n,p | d = p*p + n ) 2DUP OR IF -32768 BEGIN
DUP >R DUP M* 2OVER D- R@ UM/MOD SWAP DROP 2/ R> SWAP
?DUP WHILE - REPEAT 1- >R R@ R@ M* D- DROP R> THEN ;
CR .( Words to implement object oriented programming in FORTH )
: NEW ; ( NOOP for NEW in FORTH context )
: A_CLASS , ;
: AN_INSTANCE @ , ;
: METHOD DUP @ EXECUTE ;
: INSTANCE CREATE AN_INSTANCE DOES> METHOD ;
: CLASS CREATE A_CLASS DOES> INSTANCE ;
CR .( Example CLASS of N.Dimensions vectors )
CR .( ND> is the VOCABULARY of the METHODs )
CR .( ND is the name of the CLASS )
VOCABULARY ND> ' ND> CLASS ND
ND> DEFINITIONS
VARIABLE SIZE
: SIZE! ( size --- ) SIZE ! ;
: SIZE@ ( --- size ) SIZE @ ;
VARIABLE SAME
: SAME? ( size --- ) DUP SIZE @ = SAME ! SIZE! ;
: NEW ( size --- ) DUP SIZE! DUP , 2* ALLOT DROP ;
CR .( Example CLASS of 3D vectors )
CR .( 3D> is the VOCABULARY of the METHODs )
CR .( 3D is the name of the CLASS )
ND> VOCABULARY 3D> ' 3D> CLASS 3D
3D> DEFINITIONS
CR .( After creating these two words, let's implement the METHODs )
CR .( first : NEW for intalling an INSTANCE - for 3D, ND> NEW size = 3 )
: NEW 3 NEW ;
CR .( some unary methods : ! and @ like for 16 bits scalars and X Y Z )
: ! ( x,y,z,V --- ) DUP >R 8 + ! R@ 6 + ! R> 4 + ! ;
: X ( V --- x ) 4 + @ ;
: Y ( V --- y ) 6 + @ ;
: Z ( V --- z ) 8 + @ ;
: @ ( V --- x,y,z ) 4 + DUP @ OVER 2+ @ ROT 4 + @ ;
CR .( some binary methods : )
CR .( add two vectors : overloads scalar addition )
: + ( V,V --- V ) OVER >R @ 3 ROLL @ 3 ROLL + >R ROT + >R + R> R> R@ ! R> ;
CR .( substract two vectors : overloads scalar substraction )
: - ( V,V --- V ) OVER >R @ 3 ROLL @ 3 ROLL - >R ROT - >R SWAP - R> R> R@ ! R> ;
CR .( scaled scalar product of two vectors )
: // ( V,V,s --- scalar prpduct / s ) >R SWAP @ 3 ROLL @
3 ROLL M* 2SWAP 4 ROLL M* ROT 5 ROLL M* D+ D+ R> M/ ;
CR .( scaled vector product of two vectors : overloads */ for scalars )
: */ ( V,V,s --- vector product / s ) 2 PICK >R >R SWAP @ 3 ROLL @
4 PICK OVER M* 3 PICK 6 PICK M* D- R@ M/
4 ROLL 4 PICK M* 3 ROLL 7 PICK M* D- R@ M/
5 ROLL 3 ROLL M* 4 ROLL 5 ROLL M* D- R> M/ R@ ! R> ;
CR .( modulus of a vector )
: || ( V --- m ) @ DUP M* ROT DUP M* D+ ROT DUP M* D+ MSQRT SWAP DROP ;
CR END_FILE