-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|230|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Blogs Home -> Blogs


 
JL235
Created : 19 February 2008
Edited : 19 February 2008

:

Attack of the Colon

Over the last month I've been prototyping lots of ideas on how to improve my language. These have all been internal changes, mainly about how to represent the instructions more efficiently. Although there were some good ideas and I still want to include them, I've come to the conclusion that these should be left for later. I want to get an alpha version out soon. So I've gone back to an old Java version which I plan to complete and then release.

However I have some problems with the syntax and now is my only real chance to get it right. Changing it later is too hard and so I want to get things how I want them now. I also want something that I will enjoy writing in, as well as trying to be sparse and small so you type as little as possible. Today I've been toying with some ideas, mainly resulting in using the colon. I always liked how sparse functional languages like Haskell are, but they don't typically look like a normal language. So here is my mix of Haskell-Ruby-Basic.

Angle brackets are banned

First the blocks will not be using the angle brackets. They make the variables look too fat and I much prefer pipes. However instead I've decided to use the colon, like in SmallTalk. Here is an example for loop which will print the numbers 0 to 9.

It's less then half the length of the equivalent code in Java or C# so I'm very happy.

Begin Procedure

Next in my sights are the function declarations. Currently you can define a function as:

Although it's not that long, it's longer then in most languages. In some cases even Java, which is really something. The 'function' and 'end function' are what really annoy me. So I've been toying with a few alterations. Initially I was thinking of replacing function with def, sub or func. I don't like func because it's incomplete and I don't like sub full stop, so they are both out. Def I do like, but I feel maybe I could do more. My favorite right now is the Haskell inspired:

That could also be with the double-colon,

which makes it more authoritative because there are two. What you may also have noticed is the 'fend' instead of 'end function'. This is why I didn't like def because in my mind it doesn't match. However fend also fits in well with wend and endif. One alternative would be to use end on everything, but I don't like this much. In Ruby you do this and one of the worst bugs is when you have missed an end. It is only caught right at the end of the source file, which if it's over 1,000 lines long, means you'll be spending a long time just because you've missed it out somewhere.

Next comes the even more minimalist idea.

Function and end function are denoted through the use of => and <=. Clear, concise and easy to type.

Ultimately it's my decision and I definitely want to put my stamp on this language. But what do people think?

 

Comments


Tuesday, 19 February 2008, 15:32
Jayenkai
foo => variables
<=

looks messy.
I think it should be
foo (variables) =>

<=
Tuesday, 19 February 2008, 15:46
Phoenix
I don't like the => idea (traditional C-style curly braces would look better and more conventional if you're planning on using symbols). But the double colons do look nice.
Tuesday, 19 February 2008, 17:35
JL235
After you pointed that out, I completely agree with first Jay and then Phoenix. That option is definitely out.
Wednesday, 20 February 2008, 00:10
power mousey
label functions.



and with parameters



with parameters and return variable




and the calling functions for each one could be:

Foo

Foo->count, alpha, 10

number=Foo->count,alpha,10


.endf is a special system name for 'end fucntion'

and the symbols -> in both calling and receiving functions are for the attaching a list of parameters.

and if it follows the .endf term it means to return the value to the variable...if any...to the calling function after the operations within the function is performed. Whatever counter is or will be.


if you just call the special symbol name of endf

such as endf and it finds .endf in its system table and values then it will be used aa a certain delay or pause for some number of machine cycles. But if you attempt to use endf as a user-defined function the compiler/interpreter or scripter language will issue an error and halt compilation or interpretation.


perhaps....
have a return list of variables.
not just one and of various types too.
hmmmm...just wondering.

like .endf->counter, text$, realnum#

and the calling convention could be

[counts,name$, rnum#]=Foo->count,alpha,10
Wednesday, 20 February 2008, 02:56
Jayenkai
If you're doing "Double Colons", why not make more use out of them?


Wednesday, 20 February 2008, 03:17
Jayenkai

Wednesday, 20 February 2008, 20:15
Scherererer
no functions

don't need them

just use global variables and goto's


Thursday, 21 February 2008, 01:13
JL235
and is suggested syntax on how to do that?
Thursday, 21 February 2008, 12:16
power mousey
haha

good one, Instninct