Skip to content

Repository files navigation

LASH

LASH PROGRAMMING LANGUAGE DOCUMENTATION

Introduction

Lash is a simple, object-oriented programming language inspired by Python, C++, and Java. It is designed for readability and ease of use while maintaining powerful object-oriented features. Lash eliminates the need for "self" when accessing attributes and methods within a class, making it similar to C++ and Java.

  1. Basic Syntax

Lash uses a simple and clean syntax where variable declarations do not require var or =. The type is inferred automatically.

1.1 Variable

image1

No need for = or var Type is inferred automatically. Strings are enclosed in double quotes " ". Numbers, floats, and booleans do not require special declaration.

1.2 Type Casting

image2

to_num converts to an integer. to_str converts to a string. to_float converts to a float.

1.3 Comments

1.3.1 Single-Line Comments (#) image100

1.3.2 Multi-Line Comments (##....##) image99

  1. Input & Output

2.1 Displaying Output

image3

2.2 Taking User Input

image4

Default values can be provided: city ask "Enter city:" "New York" Multipe values: x, y ask "Enter two numbers; "

2.2.1 HOW ask WORKS IN LASH ?

The "ask" function in Lash is used to take user input in a simple and intuitive way. It works similarly to "input()" in other languages but has additional features like default values and multiple inputs.

2.2.2 HOW ask RETURNS VALUES ?

By default, ask returns a string. If you want a number, you need to convert it using to_num.

image70

2.2.3 DEFAULT VALUES IN ask

If the user presses Enter without typing anything, ask can return a default value.

image71

Example Input & Output image72

If the user enters "Los Angeles", the output will be: image73

2.2.4 Multiple Inputs in One Line

Lash allows you to space-separate multiple inputs in a single ask. image74

Example Input & Output image75

The user enters 5 10, and ask splits the input into x and y. They are converted to numbers using to_num.

  1. Operators

3.1 Airthmetic Operators

  • , - , * , / , % , **

image5

3.2 Comaprison Operators

= , != , > , < , >= , <=

image6

Example

image7

3.3 Logical Operators

and , or , not

image8

Example

image9

3.4 Assignment Operators

image50

  1. Control Flow

4.1 If-Else Statements

image10

4.2 If-Elseif-Else Statements

image11

4.3 Loops

Repeat (for loop) image12

Loop (while loop) image13

4.4 Breaking and Continuing Loops

4.4.1 Stop (Break) - Exit the loop early image60

4.4.2 Skip (Continue) - Skip current itreation image61

  1. Functions

Lash should have a simple and clean function syntax. No need for def or complex syntax—just use a keyword like fn

5.1 Definig & Calling Functions

image14

5.2 Returning Values

image15

5.3 Function with/without parameters

a.Functions without parameters image65

b.Functions with parameters image66

5.4 Functions with Return Value image67

5.5 Default Parameter Values image68

5.6 Recursive Function image69

  1. Arrays, Sets, Dictionary Functions

Lash arrays should be simple and easy to manipulate. Here’s how arrays work in Lash, along with useful built-in functions.

6.1 Creating and Accessing Arrays

image16

6.2 Modifying Arrays

image17

6.3 Array Operations

Adding Elements image39

Removing Elements image40

Checking Array Length image41

Searching image42

Sorting image43 By default, sort() sorts numbers in ascending order.

Sorting in descending order: image44

Reversing Array image45

Finding Index of an Element image46

Counting Occurrences of an Element image47

Joining Arrays image48

Slicing Array image49

6.4 Multi-Dimensional Arrays (Matrices)

Lash should support multi-dimensional arrays for matrices and sets for unique values.

A multi-dimensional array is just an array of arrays. image35

6.4.1 Multi-Dimensional Arrays(Matrices) Operations

Looping Through a Multi-Dimensional Array

image36

Getting the Number of Rows & Columns

image37

Transposing

image38

6.5 Sets (Unique Values)

A set is a collection of unique elements.

image23

6.5.1 Set Operations

Adding Elements

image29

Removing Elements

image30

Checking Membership

image31

Set Union (Combine Two Sets)

image32

Set Intersection (Common Elements)

image33

Set Difference (Elements in A but Not in B)

image34

6.6 Dictionary (Key-Value Pairs)

image24

6.7 Tuples

image28

  1. Strings and its Functions

Strings can be defined as variables are created. image51

7.1 String Functions

Finding length of a string inage52

Changing Case image53

Checking if a string contains another string image54

Replacing parts of a string image55

Splitting a string into a list image56

Joining a list into string image57

Trimming Whitespace image58

Getting a Substring image59

  1. Object-Oriented Programming (OOP)

Lash should have a simple and readable way to define and use classes and objects, avoiding unnecessary complexity.

8.1 Defining a Class

Lash uses class to define a class and fn for methods.

image19

No self! Directly access name and age inside the class.

8.2 Crating Objects

Objects are created like in C++/Java, without new.

image20

8.3 Modifying Attributes

Direct access, just like in Java/C++.

image76

8.4 Class Methods (Static Methods Like Java)

Class methods work like static methods in Java.

image77

8.5 Private Attributes & Methods

Prefix with _ to make attributes/methods private (like C++ private).

image78

_balance can’t be accessed directly outside the class.

8.5 Inheritance

No need for super – attributes are inherited directly.

image25

8.6 Encapsulation

image26

8.7 Polymorphism

image27

  1. Error Handling

9.1 Try-Catch Mechanism

image21

Conclusion

Lash is designed to be easy to learn while supporting powerful OOP features like Java and C++. It simplifies syntax while keeping familiar programming paradigms. Happy coding in Lash!

About

a compiled programming language with an easy-to-understand syntax and high performance

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages