Coder Social home page Coder Social logo

aiexandrkotov / slthree Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 658 KB

C#-injectable imperative script language

Home Page: https://slt-lang.github.io/

C# 99.80% Batchfile 0.10% Roff 0.10%
csharp programming-language script-language slt-lang language

slthree's Introduction

SLThree

.NET script programming language.

For more information about language: slt-lang.github.io

Powerful REPL with useful commands

image

Embedding

SLThree may be runned in any .NET language. Minimal version for .NET Framework is 4.7.1, for .NET Standard is 2.1.

Here code example for C#:

using System;
using SLThree;
using SLThree.Embedding;

namespace TestSLThree
{
    public class Program
    {
        public class TC
        {
            public int x, y;
            public Method sum;
            public object Sum() => sum.Invoke(x, y);
        }

        public class TC2
        {
            public Func<int, int, int> sum2;
        }

        static void Main(string[] args)
        {
            //Context.ReturnedValue method
            Console.WriteLine("return 2 + 2 * 2;".RunScript().ReturnedValue);

            //Uwrapping method
            var tc = "x = 3; y = 5; sum = (a, b) => a + b;".RunScript().Unwrap<TC>();
            Console.WriteLine(tc.Sum());

            //[Experimental] Compilation:
            var tc2 = "sum2 = (new using jit).opt(sum2 = (i32 x, i32 y): i32 => x + y, self).CreateDelegate(@System.Func<i32, i32, i32>);".RunScript().Unwrap<TC2>();
            Console.WriteLine(tc2.sum2(35, 65));
        }
    }
}

LANG and REPL compatibility

Starting from language version 0.8.0, REPL no longer supports multiple versions at once and is built for each language update.

REPL version LANG version
2.0.0 0.7.0
1.* 0.2.0 — 0.6.0

Download

stable

slthree's People

Contributors

aiexandrkotov avatar

Stargazers

 avatar  avatar

Watchers

 avatar

slthree's Issues

make this incompatibility changes later

When LANG become stable and REPL become 2 major version

make private instead public

  • ExecutionContext.global

property -> field:

  • ExecutionContext.LocalVariables

uncomment

  • slt.Program.ExtendedCommands (locals --context <contextname>)

other

  • enumerate tuples instead CreatorTuple.ToArray in LANG_030.GetChooserOutput
  • remove SLTHelpers.GetTypeString(this string t)

change priority

as => between unary and binary *, /
choosers, which, slices => binary 8

Linq methods

Linq methods supports overloading by arguments count

Base

  • count
  • select
  • select_many
  • where
  • group_by
  • order_by
  • order_by_desc
  • any
  • all

Nums

  • max
  • min
  • average
  • sum
  • max_by — вернёт максимальное значение по ключу
  • min_by — вернёт минимальное значение по ключу

Slices

  • take
  • skip

Get elements

  • first
  • last
  • first_or — вернёт первый элемент или переданный в качестве аргумента
  • last_or — вернёт последний элемент или переданный в качестве аргумента
  • element_at
  • element_random — вернёт случайный элемент

Convertions

  • tuple_enumerate — превращает ITuple в IEnumerable
  • wrap — превращает типы вроде T[], List в object[], List
  • to_dict
  • to_array
  • to_list
  • to_tuple — превращает последовательность в кортеж

generator methods

переданный в качестве первого аргумента контекст станет собственным контекстом метода

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.