Risky Business: omit do when passing a 0 arg function to a function #22

Merged
probablycorey merged 13 commits from risky-business into main 2025-11-04 15:19:54 +00:00
Owner

This is based on #21 so it may or may not merge cleanly.

Allows us to omit the do keyword when passing a zero arg function as the last argument. Moves Shrimp more towards Ruby, but without the insanity of instance_eval and method_missing - all variables and functions and scopes are still known at compile time.

## html templates
ribbit:
  head:
    title What up
    meta charset=UTF-8
    meta name=viewport content='width=device-width, initial-scale=1, viewport-fit=cover'
  end
end

list = tag ul class=list
ribbit:
  list:
    li border-bottom='1px solid black' one
    li two
    li three
  end
end

ribbit:      
  p class=container:
    h1 class=bright style='font-family: helvetica' Heya
    h2 man that is (b wild) (nospace) !
    p Double the fun.
  end
end

## tests
describe 'some tests':
  test something:
    expect (my call) | to-equal (my other call)
  end
end

## shell stuff
trap EXIT:
  file-handles | each do x: close x end
  echo Goodbye! 
end

## LOGO!
# Draw a square
repeat 4:
  forward 100
  right 90
end
    
# Move into position for the spiral
pen up
forward 150
pen down

# Draw a spiral
repeat 36:
  forward 10
  right 20
  forward 10
  right 20
end
This is based on #21 so it may or may not merge cleanly. Allows us to omit the `do` keyword when passing a zero arg function as the last argument. Moves Shrimp more towards Ruby, but without the insanity of `instance_eval` and `method_missing` - all variables and functions and scopes are still known at compile time. ``` ## html templates ribbit: head: title What up meta charset=UTF-8 meta name=viewport content='width=device-width, initial-scale=1, viewport-fit=cover' end end list = tag ul class=list ribbit: list: li border-bottom='1px solid black' one li two li three end end ribbit: p class=container: h1 class=bright style='font-family: helvetica' Heya h2 man that is (b wild) (nospace) ! p Double the fun. end end ## tests describe 'some tests': test something: expect (my call) | to-equal (my other call) end end ## shell stuff trap EXIT: file-handles | each do x: close x end echo Goodbye! end ## LOGO! # Draw a square repeat 4: forward 100 right 90 end # Move into position for the spiral pen up forward 150 pen down # Draw a spiral repeat 36: forward 10 right 20 forward 10 right 20 end ```
defunkt added 13 commits 2025-11-04 05:12:28 +00:00
defunkt changed title from risky-business to Risky Business: omit `do` when passing a 0 arg function to a function 2025-11-04 05:15:00 +00:00
probablycorey approved these changes 2025-11-04 15:19:49 +00:00
probablycorey left a comment
Owner

mergin'

mergin'
probablycorey merged commit e0e5e82869 into main 2025-11-04 15:19:54 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: probablycorey/shrimp#22
No description provided.