Talk:BrainSub
From Esolang
Would a "Hello, World!" program be:
( MAIN (72) > (101) > (108) (DUP) > (111) > (44) > (32) > (87) > (111) > (114) > (108) > (100) > (33) (<12) (.12) )
poiuy_qwert 16:26, 7 July 2007 (UTC)
No. Load Number intrinsic subroutine have in implicit >, so your example don't needs a single >. Also, I think there are 13 characters, not 12.
Of course, you can also write it this way:
( MAIN ("Hello, World!") (<13) (.13) )
Or
( MAIN ("Hello, World!") (STRSCANL) (WRITE) )
Or
( MAIN ("Hello, World!") (SL_WRITE) )
Aacini 19:08, 7 July 2007 (UTC)
Ah I see, I guess i'll Read next time instead of Skimming :P Thanks for clearing it up! poiuy_qwert 05:03, 8 July 2007 (UTC)
[edit] Multi-tape BrainSub
I think there should also be a multi-tape version of BrainSub that tapes must be defined using command:
(TAPE name parameter)
such as:
(TAPE Red /2) (TAPE Blue /1) (TAPE Green /4)
for 2-bytes values on Red tape, and 1-byte values on Blue tape, and 4-bytes values on Green tape. Possibly (for finite tapes) you could also make it you can indicate how much memory allocated for each tape:
(TAPE Red /2 200) (TAPE Blue /1 400) (TAPE Green /4 100)
Each tape is now 400 bytes long (plus the pointer). To select a tape you can use:
(Red) (Blue) (Green)
to select which tape you are working with. Also you could have a switch for binary/text I/O by doing:
(IO_BINARY_MODE) (IO_TEXT_MODE)
to set default function of , . commands, and (,) (.) do the other way. Default is IO_TEXT_MODE. If the TAPE directive is used, it uses Multi-tape BrainSub, and the current tape must be set at beginning of program, but without TAPE directive or IO_BINARY_MODE,IO_TEXT_MODE directive then it uses normal BrainSub.
Other than these things I think it is good. --Zzo38 20:52, 25 November 2007 (UTC)
This is a wonderful idea! Not just because it would provide more features to BrainSub, but because it is a good example of the possibility to use BrainSub syntax to extend language capabilities; however, the implementation have several glitches.
BrainSub code is currently compiled in accordance with element size selected via /2 or /4 compiler switch, but the multi-tape version you suggest requires that the same compiled code be executed as 1-, 2- or 4-byte instructions in accordance with the last selected tape. Although is possible to generate a program that run this way, it would be totally opposed to "efficient" BrainSub's design principle. Another way to achieve a similar result could be via a subroutine attribute that allow to compile the entire subroutine with the selected element size, for instance: ( WordSize:2 a b c ) or ( ByteSize:1 x y z ).
Anyway I don't grasp the usefulness of such feature: if the tapes are allocated in different memory areas a single tape with the larger size would do the same job. If you use the tapes to manage the same memory area as elements of different sizes then you can (soon) do the same job with PACK and UNPACK subroutines of EXTENDED.BL# object library.
BTW do you had written some stuff in BrainSub? Aacini 05:31, 10 December 2007 (UTC)

