Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Abdulazeez Abdulazeez Adeshina
@Youngestdev
So i was thinking adding more functionalities to the simple extension for vscode
Like maybe identification - like it's a function, callback etc
appcypher
@appcypher
If you can, why not. Just raise a PR and I will merge and publish.
Abdulazeez Abdulazeez Adeshina
@Youngestdev
Hehe, I actually can't. Was going to suggest that to you perhaps at your free time
appcypher
@appcypher
Oh. One of these days perhaps.
We'll see.
Abdulazeez Abdulazeez Adeshina
@Youngestdev
Great then
A Toy Soldier
@iamthecarisma_twitter
i sent a PR to fix the modules and list error simple-lang/simple#48
Abdulazeez Abdulazeez Adeshina
@Youngestdev
Okay, I just saw it. I'll check it later
A Toy Soldier
@iamthecarisma_twitter
Hello everyone simple-lang now support variadic function that can take unlimited amount of parameters which will result in the variadic keyword be a list that hold the parameters e.g the current keyword used is params having a parameter params means unlimited argument e.g
testBlock(1) 
testBlock("a string")
tesBlock([1,2],"desperado","inverse",45,87,97,new Directory("../"), [9,3,3])

block testBlock(params)
    @leghtOf(params)
a more simple example
testBlock("Hello", "World", 40)

block testBlock(params)
    @params[0] #Hello
    @params[1] #World
    @params[2] #40
A Toy Soldier
@iamthecarisma_twitter
Now what i need from you guyz before i push is that the keyword used is params but in most lang they uses ellipse ... but that will be error in simple-lang so you can decide another keyword like __VA_ARGS__, params, args
the keyword will be a secondary keyword i.e it can still be used in the code as variable name class name like any other varible unlike primary keywords like block, class
appcypher
@appcypher
I suggest using an ellipsis .... It makes it obvious that it is a varargs. Also params is a useful identifier.
A Toy Soldier
@iamthecarisma_twitter
it can still serves as an identifier
using ellipsis ... will take more scanning time as it will be added to keyword.
I ll try using the ... and give you guyz feedback
Abdulazeez Abdulazeez Adeshina
@Youngestdev

I totally agree with appcypher here. Using the ellipsis ... is better.

I suggest using an ellipsis .... It makes it obvious that it is a varargs. Also params is a useful identifier.

A Toy Soldier
@iamthecarisma_twitter

Hello guyz. Implementing the ... i hit a wall the ... is only usable in language that has type specifier e.g String str = "" but in simple lang it str = "" so the ... is not possible e.g in a block we have

block test(p1,p2,p3)

Using ... as variadic parameter

test(1,2,4,5)
block test(p1,p2,...)
    @...[0] #a big lang breaking error

or we go with C Style that will just bring a foreign identifier to fix that

test(1,2,4,5)
block test(p1,p2,...)
    @var_args[0]

Using the ... is only acceptable for strongly types language e.g java

public void functionOne(String... strings)
       System.out.println(strings[0])
buh in simple-lang we support type hinting but the ... is still not possible e.g this is valid in simple-lang
block test(String params)
    @params
A Toy Soldier
@iamthecarisma_twitter
Since we are still going to be strongly typed in future using the use strict we can have the ... on the roadmap for then
appcypher
@appcypher

I don't think ... is meant to be used as an identifier. It's more like a modifier.

So instead of the one you have above, its should actually be like this.

test(1, 2, 3, 4)
block test(p1, p2, p3...)
    return p3[0]

When types come, then it will look sth like this

test(1, 2, "Hello")
block test(Number p1, Number p2, String p3...)
    return p3[0]
A Toy Soldier
@iamthecarisma_twitter
Jez wow that is awesome.
i ll implement that
Great to have you on the simple-lang team once again @appcypher
appcypher
@appcypher
I'm sorry for not being able to contribute more as I want. I will dedicate one day next week to finishing my PR.
A Toy Soldier
@iamthecarisma_twitter
No problem the PR will wait on you
A Toy Soldier
@iamthecarisma_twitter
the variadic parameter can now be any identifier e.g p1..., 'var...' just as @appcypher suggessted
I ll send a PR to the main REPO for review
A Toy Soldier
@iamthecarisma_twitter
PR for reflection and meta programming,
simple-lang/simple#50
By merging this PR you will be able to install modules directly from github repo similar to go get ... e.g
 $ modular install Youngestdev/NgBanks
Abdulazeez Abdulazeez Adeshina
@Youngestdev
Did you know the Variadic parameter takes 0-Inf arg (
That's cool and will be useful in modules like List, Map etc
I fixed the Map module to work effectively and use the __OBJECT style.
A Toy Soldier
@iamthecarisma_twitter
Yes it accept zero arg so having it in a costructor as parameter is better and can be used for method overloading
A Toy Soldier
@iamthecarisma_twitter
Anytime you online here let talk on how modular currenlty works
Abdulazeez Abdulazeez Adeshina
@Youngestdev
Heyo
A Toy Soldier
@iamthecarisma_twitter
Hello
A Toy Soldier
@iamthecarisma_twitter
Hello everyone I am working heavily on the module. I need opinion on this idea of mine.
simple-lang parameters are passed by reference which means that object passed as argument to block remain the same and all the operation perform on the object will reflect in the actual block e.g
call simple.utilities.Console

object = new TestClass { Name = "Ade" }
treat(object)
stdout.println(object.Name) #prints Wale

block treat(obj)
    obj.Name = "Wale"

class TestClass Name = ""
A Toy Soldier
@iamthecarisma_twitter
I am thinking we should change that behaviour such that what will be sent to the block will be a copy of the original object such that the behaviour will be
call simple.utilities.Console

object = new TestClass { Name = "Ade" }
treat(object)
stdout.println(object.Name) #prints Ade

block treat(obj)
    obj.Name = "Wale"

class TestClass Name = ""
Then what will always go the block and methods by default will be a copy in this way actual object will remain safe for implementation and the block won't break it
Then optionally we can provide developer with C style of passing object by reference such that the actual object will enter the block we can use the ampersand sign ampersand for passing by reference such that behaviour will be like
call simple.utilities.Console

object = new TestClass { Name = "Ade" }
treat(object)
stdout.println(object.Name) #prints Ade
treat(&object)
stdout.println(object.Name) #prints Wale

block treat(obj)
    obj.Name = "Wale"

class TestClass Name = ""
the & before the arg will make the actual object enter the block and not a copy
Abdulazeez Abdulazeez Adeshina
@Youngestdev
Well, it's cool tho. I don't think I have experienced this ( I haven't tried this ).
Before implementing, what are the pros and cons ?
If I understand something from this block of code. The treat block value overwrites the previous value ? It looks fishy actually. The obj isn't a class ? So how does it get to work with obj.Name or am o missing something ?
A Toy Soldier
@iamthecarisma_twitter
Pros :
  • actual object remain safe
  • since an object is going to perform an op in a block it should not break the object
  • understandable code
  • yen yen yen
    Cons:
    • Developer might forgot to put thr & symbol which will not make block do unexpected behaviour
Abdulazeez Abdulazeez Adeshina
@Youngestdev
Oh, I get the obj.Name logic.
One question, what basically is the setback of the current method ?