Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 19th, 2010, 04:14 PM
delnan delnan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 383 delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Week 7 h 31 m
Reputation Power: 0
Other Language - St*ck - brainf*ck with stack

Being a big fan of esoterical languages, I recently ran into a precious piece of insanity called Stacked Brain****. I even started writing an interpreter for it in D. There are more bf-inspired languages with stack (Brainstack and Stackf*ck), but the first rather misses the idea of minimalism by having both cells and a stack (inc. commands for both), and the latter still has a memory cell and simply pushed/pops this cell.
Suddenly, the thought the this idea could be taken further emerged... a single stack - no (accessable) other memory - and only 8 commands of vanishingly small power to operate on it.
St*ck was fathered, and now I'd appreciate some comments on what I figured out so far, so the child may be born without malformations.
One note on turing completeness: I don't have any idea, but as the semantics are rather close to bf, just with a stack instead of a tape, it may be turing-complete.
----------

St*ck has a single Stack. If this stack is limited, what the limit is, and what size each item has, is up to the implementation. As with traditional brain****, formatting and non-command characters are ignored. So far, the commands are as following:
Code:
Command | Meaning
    ^   | push previously popped value, or 0
    v   | pop (remember for subsequent push)
    +   | increment top item
    -   | decrement top item
    .   | output top item as ASCII char (peek, i.e. do not pop)
    ,   | push input
    [   | jump past matching ] if top item == 0 (peek)
    ]   | jump back to matching [ if top item != 0 (peek)

As said, any feedback is welcome.

Reply With Quote
  #2  
Old March 21st, 2010, 01:33 AM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,938 Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 h 43 m 16 sec
Reputation Power: 1312
Quote:
Originally Posted by delnan
As said, any feedback is welcome.
You might get a better response if you show some example programs. (And of course, you'll get a better feel for the language in the process of creating them.)

Reply With Quote
  #3  
Old March 21st, 2010, 05:07 AM
delnan delnan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 383 delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)delnan User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Week 7 h 31 m
Reputation Power: 0
Well then, I'll stick to the traditional hello, World. As st*ck's "tape" is unlimited only on one side, but limited to one on the other, the clever "approximate all character values in one big loop" doesn't work. But loops are still useful.
Code:
// approximate "!" (dec 33 = 3x10 plus 3) by loop
+++ // set top item (loop counter) to 3
[
  v
  ++++++++++ // add 10 to top item
  ^ - // push loop counter and dec it
]
v +++ ^ // finish counting to !: 30 plus 3 = 33 = !
// now loop counter is 0 and ! is on the stack
^ // push new loop counter (old loop counter becomes next char)
// same principle for remaining chars: dlroW *space* *comma* olleH

// d = 100 = 10x10
++++++++++
[
  v
  ++++++++++
  ^
]
^

// l = 108 = 10x11 minus 2
++++++++++
[
  v
  +++++++++++
  ^
]
v -- ^^

// r = 114 = 11x10 plus 4
+++++++++++
[
  v
  ++++++++++
  ^
]
v +++ ^^

// o = 111 = 11x10 plus 1
+++++++++++
[
  v
  ++++++++++
  ^
]
v + ^^

// W = 87 = 9x10 minus 3
+++++++++
[
  v
  ++++++++++
  ^
]
v --- ^^

// space = 32 = 5x6 plus 2
+++++
[
  v
  ++++++
  ^
]
v ++ ^^

// comma = 44 = 4x11
++++
[
  v
  +++++++++++
  ^
]
^

// o again
+++++++++++
[
  v
  ++++++++++
  ^
]
v + ^^

// l = 108 = 11x10 minus 2
+++++++++++
[
  v
  ++++++++
  ^
]
v -- ^^

// l again
// as only the last item popped is preserved
/ /we cannot alter more than two items
// (character and loop counter) within one loop
// however, we can output the same item twice
// since the dot does not pop but peek

// e = 101 = 10x10 plus 1
++++++++++
[
  v
  ++++++++++
  ^
]
v + ^^

// H = 72 = 7x10 plus 2
+++++++
[
  v
  ++++++++++
  ^
]
v ++ ^^

// now, the stack contains "Hello *comma* *space* World!" (in reverse order)
. // output latest char: "H"
v // pop manually, as dot does only peek
// etc cetera:
.v // "e"
.  // "l" no pop because "Hello" has to l
.v // second "l"
.v // "o"
.v // comma
.v // space
.v // "W"
.v // "o"
.v // "r"
.v // "l"
.v // "!"

Untested, of course, since there is no implementation.
And I wouldn't be to surprised if there is a more efficient way...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Other Language - St*ck - brainf*ck with stack

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap