The Unnamed Scripting Language

Programming, for all ages and all languages.
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: The Unnamed Scripting Language

Post by iansjack »

eryjus wrote:I don't dare say anything about Basic for fear of getting my butt kicked by Combuster :lol:
Just about all that Visual Basic shares with BASIC is the name. It's a good enough language, although one that I have no reason to use.
SoulofDeity
Member
Member
Posts: 193
Joined: Wed Jan 11, 2012 6:10 pm

Re: The Unnamed Scripting Language

Post by SoulofDeity »

Settling out the syntax a bit...

Comments will begin with '#', or be surrounded by '#*' and '*#' for blocks. There will 7 data types: numbers, symbols, strings, vectors, sets, patterns, and literals. These are self explanatory with the exception or the pattern and literal types. A pattern is an expression beginning with '<' and ending with '>' with the operators '+', '-', '*', and '/', a '.' for wildcards, and ',' for concatenation. They're like regular expressions:

Code: Select all

< x , "text" >                    # match the value of x followed by the string "text"
< x / y , "text" >                # match x or y followed by text
< 2 * x , "text" >                # match x 2 times followed by text
< 2 + 2 * x, "text" >             # match x 2-4 times followed by text
< 4 - 1 * x, "text" >             # match x 3-4 times followed by text
< 1 - . * x , "text" >            # match x zero or one times followed by text
< 1 + . * x , "text" >            # match x one or more times followed by text
< 0 + . * x , "text" >            # match x zero or more times followed by text
< (x+8) >                         # match the value of the expression x + 8
< < x , y > / z >                 # match x followed by y or z
Patterns are particularly used in function declarations. When you pipe a stream to a function with a pattern, the function will be executed with an argument for a set representing a directed acyclic graph for the input stream based on the pattern. In other words, the language will be really damn good at parsing things quickly and easily. Including itself.

The second thing, literals, are used to declare things 'literally'. eg. if you defined 'x' as '1+1', this would normally be evaluated and 'x' would be set to '2'. With literals, you can tell the compiler, 'no, go screw yourself, I said 1+1'. It's particularly used for declaring macros like:

Code: Select all

if:    `('
then:  `)?:{'
end:   `}'

let:;
be: `:';
which turns

Code: Select all

x : 5;
(x = 5)?:{
  print "hi";
}
into

Code: Select all

let x be 5;

if x = 5 then
  print "hi";
end
It's like C macro's, but more powerful and integrated into the language itself. Below is an example of the current syntax I have in mind:

Code: Select all

#* Main entry point function (fake) *#
main: argc argv
  {
    s: "Hello World!\n";
    x, y: 5, 6;

    (x = 5)?
      print s;

    # This is a 'do' block piping "Hello World!" to magic.
    :
      {
        s >> magic;
      }

    # This is an 'on' statement for receiving signals
    !error
      print "Error: Invalid input stream.\n";

    # Run a program...literally...
    $ `cc -o example example.c'
  }

#* This is a magic pattern function! *#
magic:<"Worl">
  {
    print "It's magic!";
  }
You can probably tell from the syntax that what I'm going for is a very meta pure-functional language with no keywords; letting the user define their own macros to deal with that.
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: The Unnamed Scripting Language

Post by kzinti »

So you are rediscovering lisp? =)
SoulofDeity
Member
Member
Posts: 193
Joined: Wed Jan 11, 2012 6:10 pm

Re: The Unnamed Scripting Language

Post by SoulofDeity »

kzinti wrote:So you are rediscovering lisp? =)
Like I said before, I'm taking inspiration from many languages, including Tcl, Lisp, VB, Go, Perl, and Bash. The idea is to make a very malleable language that makes difficult or tedius things easy to do.

Also, I've been thinking a lot about threading lately (mostly for my OS, not this). I want to introduce "strands". They're isolated sets of interconnected threads and fibres. Essentially the same concept as a .NET AppDomain. Each process has at least 1 strand, but can have several.
Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

Re: The Unnamed Scripting Language

Post by Ready4Dis »

I honestly don't get it. Why not just use // and /* */ for comments to make it more familiar feeling? What's the difference in parsing a do before a bracket or just checking for a bracket? Why need the extra keyword? Why can't functions just be functions with parameters, why do you need $0, $1, $2 (reminds me of working with batch files)? I understand you're trying to take parts of many languages and put them together, I just question your choices of which parts to take. You said early that determining that gcc was an external call and your function is a function is a problem. Then you changed it later to put a $ in front of the program call. That solves the problem of needing to differentiate between the two, so there is no reason for your silly declaration.

Using your little script thing, how is that any different than:

Code: Select all

/* Main entry point function */
main(argc, argv)
{
	s = "Hello World!\n";
	x = 5;
	y = 6;

	if (x == 5)
	{
		print(s);
	}

	//This is a block to output Hello World! to magic
	{
		magic(s);
	}

	//This checks for an error signal
	if (was_error())
	{
		print("Error: Invalid input stream.\n");
	}

	//run an external program
	run("cc -o example example.c");
}

/* Not even sure what this is supposed to do? */
magic(value)
{
	print("It's magic!");
}
Yes, it looks almost C like.. which makes it familiar. How is this any worse or better than what you have? It's just as easy to parse (if not easier) and isn't missing any features. Anyone who has seen C or Java or C++ can easily see what's going on, where it would take a bit to figure out what you're doing with your stuff? I just don't see any of the merits honestly.

Also, your let/be stuff, I dont' see any difference between the two. They both perform the same function, what exactly is the difference besides syntax?

I don't really see what the point of the pattern matching is for either, what exactly would it be used for? How would it be used, and what is it's purpose?

Maybe I just don't have to same needs, but I just don't see how this really makes anything easier.
Post Reply