I created blocks that might enable text-based programming

I would appreciate it if you could let me know if you find any bugs or have any feature requests.

I take it that’s assembly language for some computer? Which?

No, it was not created by emulating any specific assembly language or computer.

Oh. Well how are we supposed to debug it if we don’t know what it’s meant to do?

Shall I explain in detail?

Up to you, but if you want people to understand it…

  • Specifications -

vcre function: Takes two arguments (1st: variable identifier, 2nd: initial value); creates a variable.
vset function: Takes two arguments (1st: variable identifier, 2nd: setting value); sets the variable’s value to the specified value.
vadd function: Takes two arguments (1st: variable identifier, 2nd: value to add); adds the specified value to the variable.
vsub function: Takes two arguments (1st: variable identifier, 2nd: value to subtract); subtracts the specified value from the variable.
vtov function: Takes two arguments (1st: first variable identifier, 2nd: second variable identifier); sets the value of the second variable to that of the first variable.
mrst function: Takes no arguments; clears the memory (resets it to an empty list).
madd function: Takes one argument (value to add); adds the specified value to the memory.
mdel function: Takes one argument (index number); deletes the item at the specified index in the memory.
mget function: Takes one argument (index number); stores the value at the specified index in the memory into the mv variable.
mtov function: Takes one argument (variable identifier); assigns the value of the mv variable to the specified variable.
ret function: Takes no arguments; returns all variables except the mv variable.

Actually pretty useful. This gives me the idea, if you can run any kind of “bytecode” (this is more like a simple bytecode interperter, but string-based), could you write a python interpreter in Snap! (probably not, but maybe…)

Can you update the title to something like “basic programming language”? Something like that to make sure people can identify it.

We could, but I don’t want to.

Ah. Thank you.

The first thing I tried was to insert vadd(a,a) just before the ret in your sample program and was sad that it didn’t work. Your variables would be much more useful if your language allowed a variable name in a value input slot.

I hate to sound like the College Board, but if you want your language to be able to run any algorithm, you need some way to run code conditionally and some kind of loop mechanism. Or, alternatively, a way to call functions. :~)

I spent my first several years as a programmer working in the machine language of the PDP-10 computer, so a language like this, at a low level of abstraction, brings back fond memories.

It is now possible to use variables for the second argument of the vcre, vset, vadd, and vsub functions.

Next, I’ll add the conditional statements.

Yay! :~D

Conditional statements have been added (however, else and elseif are not supported, and the “not equal” (!=) operator cannot be used in the condition).
Usage:
if (condition) [
code
]
Examples of conditions (same applies to < and >):
・a = 1
・1 = a
・1 = 1
・a = a
・a = b

Major issue: You cannot use two if statements.

will fix it.

This is the worst.
I tried to make it possible to use two or more if statements, but I couldn’t do it.

If you have trouble replying to your topic in general rather than replying to someones post, remember it is the big blue reply button at the bottom of the topic.


As for your problem, can you tell what went wrong?

IF statements aren’t actually done the way you’re familiar with. In computer assembly, they look like this.
(for nerds: yes, this assembly is pseudocode. i just want to get my point across)

jmpif condition, thing
not condition
jmp otherThing
.thing
 doAThing
 jmp exit
.otherThing
 doSomethingElse
.exit

Here’s how it works. The “instruction pointer” points to the code that you’re currently running. In your code, it’s i.
I_is_the_IP
JMP “jumps” to a target point by setting the IP’s value. Here’s a demo making a forever loop.

.beginForeverLoop
 doSomething
 jmp beginForeverLoop

JMPIF jumps to a place if a condition is true. We can use this to add an exit condition to our forever loop, or make if statements (see the front of the post).

How would you add this to your current language?
I’d suggest something like this

vcre(a,1)
jumpif
.one
madd("It's one!")
jmp(exit)
.notone
madd("It's not one!")
.exit

This is an extremely different approach to if statements, and if it doesn’t line up with your current vision of the language, it’s alright to ignore it.

It seems like your current approach to if statements is regex-based. You’ll need a lexer and parser (aka a lot of work) if you want to add good if statements (as well as strings with commas, they’re not supported yet)

I thought of suggesting that, too, but before he invents jump instructions he has to invent labels, which involves (probably) a pre-processing pass over the code to build a symbol table.

You could always just use the item # of block to find labels and skip a line if it starts with a dot. It’s not true to bytecode, but it is easy.

No, the point is, if you say jmpif condition, thing then you have to know where .thing is. You don’t want to have to scan the whole program from the beginning each time through a loop! So you have to be able to look up that .thing is at location 4 or whatever.

Also, unless you think of a .label line as occupying a slot in memory, I would argue for combining the label with the instruction it labels, like this:
thing: doAThing
which is how assembly languages did it in the old days.