### Charles Yates

General Discussion -Probably a dumb idea, but I've always liked Reverse Polish Notation and the FORTH language - hacked this up as an alternative way to use openjscad:

function main( )

{

return new stack( ) // Create stack

.push( cube( ) ) // Push a cube

.dup( ) // Duplicate the top of stack

.push( [ 1, 1, 0 ] ) // Push coordinates

.translate( ) // Translate

.union( ) // Join the two objects

.push( 10 ) // Push 10

.scale( ) // Scale

.pop( ); // Return top of stack

}

or:

function main( )

{

return new stack( ) // Create stack

.push( cube( ) ) // Push a cube

.push( "dup" ) // Duplicate the top of stack

.push( [ 1, 1, 0 ] ) // Push coordinates

.push( "translate" ) // Translate

.push( "union" ) // Join the two objects

.push( 10 ) // Push 10

.push( "scale" ) // Scale

.pop( ); // Return top of stack

}

eventually, I'd like to support:

function main( )

{

return new stack( ).push( cube ).push( "dup [ 1,1,0 ] translate union 10 scale" ).pop( );

}

along with FORTH-style word definitions, but that's probably just getting silly :p.

Dunno if it scales very well, or if there'd be any interest in such an approach, but thought I'd bounce it here and see if anyone is interested (or just wants to point and laugh :)).

function main( )

{

return new stack( ) // Create stack

.push( cube( ) ) // Push a cube

.dup( ) // Duplicate the top of stack

.push( [ 1, 1, 0 ] ) // Push coordinates

.translate( ) // Translate

.union( ) // Join the two objects

.push( 10 ) // Push 10

.scale( ) // Scale

.pop( ); // Return top of stack

}

or:

function main( )

{

return new stack( ) // Create stack

.push( cube( ) ) // Push a cube

.push( "dup" ) // Duplicate the top of stack

.push( [ 1, 1, 0 ] ) // Push coordinates

.push( "translate" ) // Translate

.push( "union" ) // Join the two objects

.push( 10 ) // Push 10

.push( "scale" ) // Scale

.pop( ); // Return top of stack

}

eventually, I'd like to support:

function main( )

{

return new stack( ).push( cube ).push( "dup [ 1,1,0 ] translate union 10 scale" ).pop( );

}

along with FORTH-style word definitions, but that's probably just getting silly :p.

Dunno if it scales very well, or if there'd be any interest in such an approach, but thought I'd bounce it here and see if anyone is interested (or just wants to point and laugh :)).

1

15 comments

Ditto. Let me know when you have time. Preferably on the weekend.

Add a comment...