Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tea expression language ideas #865

Closed
1 of 6 tasks
andychu opened this issue Nov 29, 2020 · 6 comments
Closed
1 of 6 tasks

Tea expression language ideas #865

andychu opened this issue Nov 29, 2020 · 6 comments

Comments

@andychu
Copy link
Contributor

andychu commented Nov 29, 2020

Continued from #835

Tea Language

Semantic changes

  • I think we need a ?? operator that is like or, except it returns the first argument if it's non-null (None), not if len(x) == 0. This matches C semantics.
    • this replaces ${x:-'default'} too? That currently doesn't work on integers. It can be $[x ?? 'default'] instead
  • I don't like in on lists (fixed too many accidentally quadratic bugs). It good for dicts, and maybe acceptable for strings ...

Prettier

  • multiline strings should strip leading space of closing delimiter (and probably disallow anything on first line?)
  • removed in favor of $[x] and _ESCAPE Tagged prefixes for strings. In addition to r'foo', maybe we want html'foo' or html"foo", sql'foo'
    • or we could copy JS strings which use backticks
  • (Tea language) Func[Int, Str => Int] instead of Func[[Int, Str], Int]
  • maybe optional sigils like push!(x) and even?(i)

New functionality:

@andychu
Copy link
Contributor Author

andychu commented Feb 12, 2021

The FAQ brought up the => vs. |> issue:

http://www.oilshell.org/blog/2021/02/new-faqs.html

A bunch of possible ways to write this:

var line =  _line.strip()
var line =  _line |> strip()
var line =  _line => strip()

_ _line => strip() => var line  # it's annoying that there's a _ here

_ _line |> strip() |> var line

Maybe we can have a keyword in addition to _, like

exp _line => strip() => var line  # exp and not expr ?  pass was ruled out.  

Note Ubuntu has exp in alliance package, which is a calculator: http://manpages.ubuntu.com/manpages/trusty/man1/exp.1.html

EXPR _line => strip() => var line
Expr _line => strip() => var line  # this is possible ...

Also someone brought this up:

=> _line => strip() => var line
|> _line |> strip() |> var line  # possible problem: |> is two tokens that would require lookahead

Actually => is not that bad:

  • We're already detecting = as a keyword`
  • We might detect _ <span>foo</span> as a keyword for "Pulp"

@andychu
Copy link
Contributor Author

andychu commented Feb 20, 2021

Random idea from https://oilshell.zulipchat.com/#narrow/stream/121540-oil-discuss/topic/left-to-right.20syntax.20ideas

Allow obj!method() for mutating methods, in addition to obj.method()! It could be a matter of convention.

Or it could be the more conventional:

obj.method!()
myfunc!(x)

Or the ! could tell you which one is mutated!

obj.method!(x)  # mutates x
obj!method(x)  # mutates obj

@andychu
Copy link
Contributor Author

andychu commented May 16, 2021

Idea: get rid object.method() syntax altogether

Get rid of _ mylist.append(x)

Maybe:

append :mylist foo bar

_ append(mylist, %(foo bar))

# if parse_paren is on:


append(mylist, %(foo bar))

  • ksh style function definition can still be used for the latter
    • function f { echo hi }
    • though very discouraged!
  • problem: doesn't this break EVERYTHING in Oil?
    • I guess it only breaks f(), it doesn't have to break f(arg)
  • f( - ) could be an alternate? Or call f(), or _ f()

@andychu
Copy link
Contributor Author

andychu commented Jul 18, 2021

Related to #950

@andychu andychu changed the title Enhancements to expression language Tea expression language ideas Sep 2, 2021
@andychu
Copy link
Contributor Author

andychu commented Sep 2, 2021

Oil issues moved to #980. This is now low priority

@andychu
Copy link
Contributor Author

andychu commented Oct 30, 2023

This experiment is obsolete -- we're now doing a Yaks IR first, with Lispy syntax

See #yaks channel on Zulip

@andychu andychu closed this as completed Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant