bhai-lang icon indicating copy to clipboard operation
bhai-lang copied to clipboard

Adding Function (Funda) for #170

Open thecodacus opened this issue 2 years ago • 30 comments

This PR closes issue #154 and Based on #170, this will be the first stage to make it more like a real programming language.

added Functional Programming features,

you can now create funda (functions) to make your code modularized, and not repeat yourself

example

hi bhai
apna funda test(c){
  bol bhai c;
  rakh le bhai "return bhi "+c;
}
bol bhai test("kam kiya bhai");
bye bhai

output

kam kiya bhai
return bhi kam kiya bhai

thecodacus avatar Mar 18 '22 13:03 thecodacus

Deploy Preview for bhailang-preview ready!

Name Link
Latest commit a2b0d83a4778cf99a4272f41b1f922a58611f871
Latest deploy log https://app.netlify.com/sites/bhailang-preview/deploys/63848e08619000000829e06f
Deploy Preview https://deploy-preview-220--bhailang-preview.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Mar 18 '22 13:03 netlify[bot]

This pull request introduces 6 alerts when merging 74b5630d647d2c281d3f49e0f6bc2488857ff033 into fc11311a092c9e62511f1933e25850c0e5a5ddc5 - view on LGTM.com

new alerts:

  • 2 for Illegal invocation
  • 2 for Unneeded defensive code
  • 1 for Useless conditional
  • 1 for Comparison between inconvertible types

lgtm-com[bot] avatar Mar 18 '22 15:03 lgtm-com[bot]

This pull request introduces 4 alerts when merging 774d9c13e6cd130011929509445f9c6ef7051f1c into fc11311a092c9e62511f1933e25850c0e5a5ddc5 - view on LGTM.com

new alerts:

  • 2 for Unneeded defensive code
  • 1 for Useless conditional
  • 1 for Comparison between inconvertible types

lgtm-com[bot] avatar Mar 18 '22 15:03 lgtm-com[bot]

This pull request introduces 3 alerts when merging fc93884ac3262a697a10158d1c80bf4cce5a86ae into fc11311a092c9e62511f1933e25850c0e5a5ddc5 - view on LGTM.com

new alerts:

  • 2 for Unneeded defensive code
  • 1 for Comparison between inconvertible types

lgtm-com[bot] avatar Mar 18 '22 15:03 lgtm-com[bot]

This pull request introduces 2 alerts when merging 0ffb32efa626e44dd94b5b7bf7eaa38e334b04b1 into fc11311a092c9e62511f1933e25850c0e5a5ddc5 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 18 '22 16:03 lgtm-com[bot]

Great work! will check.

ankitchouhan1020 avatar Mar 18 '22 17:03 ankitchouhan1020

hi bhai

apna funda Counter() { 
  bhai ye hai count = 1;
  
  apan funda increment() {
    count += 1;
    rakh le bhai count;
  }
  
  rakh le bhai increment;
}

bhai ye hai tick = Counter();
bol bhai tick();

bye bhai

Does it support closures ? Not working in preview.

ankitchouhan1020 avatar Mar 18 '22 17:03 ankitchouhan1020

hi bhai

apna funda Counter() { 
  bhai ye hai count = 1;
  
  apan funda increment() {
    count += 1;
    rakh le bhai count;
  }
  
  rakh le bhai increment;
}

bhai ye hai tick = Counter();
bol bhai tick();

bye bhai

Does it support closures ? Not working in preview.

you have a typo "apan" the keyword is "apna" also I just fixed few bugs, it should be working now

image

thecodacus avatar Mar 18 '22 18:03 thecodacus

This pull request introduces 2 alerts when merging 3336243b2c592dd716952363ab12f5484e57b79a into 0181ca41abb64cff477b3028db13219bf501eaf7 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 18 '22 19:03 lgtm-com[bot]

This pull request introduces 2 alerts when merging 3dc5b92ef5ac403b4057f4ab0d72b6a637b0d55b into 0181ca41abb64cff477b3028db13219bf501eaf7 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 18 '22 19:03 lgtm-com[bot]

Great work @thecodacus.

I will look into this. I was thinking to have duck typing in the functions. But this will also work

tbhaxor avatar Mar 19 '22 05:03 tbhaxor

Shouldnt we have it outside hi bhai? Like other languages? Hi bhai is the execution entry point

tbhaxor avatar Mar 19 '22 07:03 tbhaxor

Shouldnt we have it outside hi bhai? Like other languages? Hi bhai is the execution entry point

with the current setup, anything that is outside "hi bhai" is discarded, I am working on "include" features then will try to change this in a new PR

thecodacus avatar Mar 19 '22 09:03 thecodacus

This pull request introduces 2 alerts when merging 49480494b071b4c5f3b9a0039d262088a955b272 into 0181ca41abb64cff477b3028db13219bf501eaf7 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 19 '22 13:03 lgtm-com[bot]

@ankitchouhan1020 if this looks good can we close this PR?

thecodacus avatar Mar 19 '22 13:03 thecodacus

This pull request introduces 2 alerts when merging f53d781de9276dd8c97c72a5f80aad63722869bf into 0181ca41abb64cff477b3028db13219bf501eaf7 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 19 '22 13:03 lgtm-com[bot]

We'll look into this PR. As its quite large PR we'll take some time. Anyway thanks for working on this.

aniketsingh0104 avatar Mar 19 '22 18:03 aniketsingh0104

This pull request introduces 2 alerts when merging f89fc4f3108a7ef639f379c3eb69ad63006cd5af into a789449c98545de0e23d66968e25ad2eeabd9396 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 20 '22 04:03 lgtm-com[bot]

This pull request introduces 3 alerts when merging c06b202498ba7af06d2d4dd4e9e232254c1e638f into dd076b3ec71113c29fe63c58128a7ffc7dd7d7c9 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Syntax error
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 21 '22 09:03 lgtm-com[bot]

This pull request introduces 2 alerts when merging bd11d036990c56e3a61a43e6e6f4003f7d641694 into dd076b3ec71113c29fe63c58128a7ffc7dd7d7c9 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 21 '22 10:03 lgtm-com[bot]

This pull request introduces 2 alerts when merging 3853cf82572a60a46bc5309130a523dd0b1b7544 into dd076b3ec71113c29fe63c58128a7ffc7dd7d7c9 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Mar 21 '22 13:03 lgtm-com[bot]

@ankitchouhan1020 @aniketsingh0104 or @ristri - could one of you review and approve the PR to be merged with the develop branch? This is such a cool and important feature. Eager to see this spreading against after playing around with this a bit in the netlify preview playground.

shankarkrupa avatar Apr 04 '22 15:04 shankarkrupa

To be reviewed this week.

aniketsingh0104 avatar Apr 05 '22 02:04 aniketsingh0104

Complete Review would be only possible after the test cases are included.

aniketsingh0104 avatar Apr 09 '22 18:04 aniketsingh0104

Complete Review would be only possible after the test cases are included.

Thanks for the review till now, I will make the changes and add test cases

thecodacus avatar Apr 09 '22 19:04 thecodacus

This pull request introduces 2 alerts when merging 567b961b0999fe40a782a979026dbed744f652ed into de68714357e159719b85fae34c0df58d4ba5ce81 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

lgtm-com[bot] avatar Jul 30 '22 08:07 lgtm-com[bot]

Critical: I see test cases are missing from this change specially from Parser. We won't review any PRs which do not contain proper test cases. Please write proper test cases covering positive and negative scenarios for both PARSER and INTERPRETER.

test cases added

thecodacus avatar Jul 30 '22 09:07 thecodacus

took me a while to get the time and make the changes :) @aniketsingh0104 please check the changes

thecodacus avatar Jul 30 '22 09:07 thecodacus

This pull request introduces 2 alerts when merging a2b0d83a4778cf99a4272f41b1f922a58611f871 into de68714357e159719b85fae34c0df58d4ba5ce81 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types
  • 1 for Unneeded defensive code

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine :gear: that powers LGTM.com. For more information, please check out our post on the GitHub blog.

lgtm-com[bot] avatar Nov 28 '22 10:11 lgtm-com[bot]

Can this be merged, looks very useful bhai

Moulick avatar Mar 21 '23 11:03 Moulick