OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 2:22 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: The Unnamed Scripting Language
PostPosted: Thu Feb 26, 2015 10:16 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
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.


Top
 Profile  
 
 Post subject: Re: The Unnamed Scripting Language
PostPosted: Sun Mar 01, 2015 9:36 am 
Offline
Member
Member

Joined: Wed Jan 11, 2012 6:10 pm
Posts: 193
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:
< 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:
if:    `('
then:  `)?:{'
end:   `}'

let:;
be: `:';

which turns
Code:
x : 5;
(x = 5)?:{
  print "hi";
}
into
Code:
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:
#* 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.


Top
 Profile  
 
 Post subject: Re: The Unnamed Scripting Language
PostPosted: Mon Mar 02, 2015 1:43 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
So you are rediscovering lisp? =)

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: The Unnamed Scripting Language
PostPosted: Wed Mar 04, 2015 7:28 am 
Offline
Member
Member

Joined: Wed Jan 11, 2012 6:10 pm
Posts: 193
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.


Top
 Profile  
 
 Post subject: Re: The Unnamed Scripting Language
PostPosted: Mon Sep 14, 2015 7:04 am 
Offline
Member
Member

Joined: Sat Nov 18, 2006 9:11 am
Posts: 571
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:
/* 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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 131 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group