# Hello Constructions in Processing

**URL:** <https://discourse.processing.org/t/hello-constructions-in-processing/44191>\
**Category:** Processing\
**Created:** [March 31, 2024, 12:53pm UTC](https://discourse.processing.org/t/hello-constructions-in-processing/44191 "2024-03-31T12:53:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zlfp](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zlfp/32/19543_2.png) [@zlfp](https://discourse.processing.org/u/zlfp)\
**Post date:** [March 31, 2024, 12:53pm UTC](https://discourse.processing.org/t/hello-constructions-in-processing/44191/1 "2024-03-31T12:53:08Z")

</div>

hello developers (of processing)  
let’s do some opportunity to other developers create some cycles and constructons (construsions like if, else if, else …)  
im have an workpiece for that

let’s create an match-case like in python

```auto
void match(Unlinted what) [!endless case(Unlinted with)] [this.code, this.argument] {
    for (Unlinted i = 0; i <= case.length;i++) {
        if (match.argument == case[i].argument || case[i].argument == null) {
            eval(case[i].code);
            break;
        }
    }
} 

```

this will be like that

```auto
match ("youre argument1") {
    // this part of code just ignores
} case ("youre argument2") {
    // match-case do this part of code and go out of match-case, if youre argument1 == youre 
    // argument2
} case ("youre argument3") {
    // same as first case but youre argument 2 is youre argument 3
    // and so forth
} case (null) {
    // this part of code be fulfilled Necessarily
}

```

and now analysis of the incomprehensible

```auto
//Unlinted tipe
//this tipe is tipe for unlinted tipe of variable

// void [] []

// first [] is tipes of additional constructions like else if and else for if
// also !endless and endless is types of additional constructions
// !endless is not break the constuction after doing
// endless is break the constuction after doing
// enother part of first [] is name of additional construction and arguments

// second [] is a code and argument notation
// first is code and second is arguments

// eval just do code in quotes  

```

this is just this wery useful construcion for writing code  
and will attract the other programers, thanx😊

---

<div class="post-metadata">

**Author:** ![JoseMY](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josemy/32/2016_2.png) [@JoseMY](https://discourse.processing.org/u/JoseMY)\
**Post date:** [April 7, 2024, 9:33am UTC](https://discourse.processing.org/t/hello-constructions-in-processing/44191/2 "2024-04-07T09:33:35Z")

</div>

Why not use the traditional switch / case? Maybe you are looking for a runtime-modifiable case statement?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [April 7, 2024, 11:23am UTC](https://discourse.processing.org/t/hello-constructions-in-processing/44191/4 "2024-04-07T11:23:48Z")

</div>

> [@zlfp](#):
>
> let’s create an match-case like in python

Java has no equivalent to Python’s `eval()` function so unfortunately it is not possible to achieve what you describe.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [April 7, 2024, 5:26pm UTC](https://discourse.processing.org/t/hello-constructions-in-processing/44191/6 "2024-04-07T17:26:09Z")

</div>

> [@zlfp](#):
>
> let’s create an match-case like in python

Based on what you have said here and in private PMs you sent to me I believe that you are proposing that the developers of Processing create a `match-case` construct for Java.

Now @JoseMY asked two valid questions to try and clarify the situation and give you an opportunity to discuss the issue in more detail. Your reply

> [@zlfp](#):
>
> try understand the code

was less than helpful especially as the code was neither valid Python or valid Java syntax,.

> [@zlfp](#):
>
> im know java haven’t `eval()`, and this is realy suck’s, there is `eval()` just for `eval()` add to processing java,

So you are unhappy that Java does not have an `eval()` function. Well Java has been around since ~1995 without `eval()` so perhaps there is no real need / demand for it. Both Javascript and Python have an `eval()` function but they must be used with care because they can pose a security risk.

I am not a Python programmer but my research indicates that the programmer can use pattern matching for the case selectors in `match-case` where Javas `switch-case` is mostly restricted to primitive types and String. Something like this in Java would be nice even without the capability of executing arbitrary strings with `eval()`.

---

<div class="post-metadata">

**Author:** ![JoseMY](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josemy/32/2016_2.png) [@JoseMY](https://discourse.processing.org/u/JoseMY)\
**Post date:** [April 7, 2024, 8:01pm UTC](https://discourse.processing.org/t/hello-constructions-in-processing/44191/7 "2024-04-07T20:01:58Z")

</div>

I though the question was javascript (p5js) related, due the use of eval().Maybe you could pass a function object as parameter?

In other words, pass (function){blah blah blah} instead of eval? I have few experience with actual java, most of my code is limited to basic java functions and the processing API.
