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

New syntax extension #19

Closed
Drup opened this issue Aug 30, 2013 · 5 comments
Closed

New syntax extension #19

Drup opened this issue Aug 30, 2013 · 5 comments

Comments

@Drup
Copy link
Member

Drup commented Aug 30, 2013

I'm planning to do a new syntax extension, using the new extension-point mechanism and following some ideas from Alain Frisch.
The syntax would look like this :

let@sh bla = 3 (* A shared declaration *)
let@s blu = "blu" (* A server declaration *)
let x = ( "blop" )@cval (* A client value *)

[%%client ] (* The beginning of a server section *)
let a = ... 
let b = ...

There is something a bit touchy : injections. I havn't study the question enough to have an opinion on it.

I didn't even begin to work on this, and we have quite some time since extension-points just got only merge on the trunck. Any feedback on the syntax and ideas about this would be appreciated.

hopefully, this new syntax should fix some bugs like #18.

@ghost ghost assigned Drup Aug 30, 2013
@Drup
Copy link
Member Author

Drup commented Apr 15, 2014

What I'm thinking for now :

  • For top level declarations [%%client ... ] [%%server ... ] and [%%shared ... ] instead of {client{ ... }} {server{ ... } and {shared{ ... }}.
    As added bonus, let%server = .... will work at the toplevel. Also, since the syntax is going to be slightly different than the one for expressions, it may help solve an ambiguity for beginners.
  • For client values, I propose ( ... )[@cval ty] instead of {ty{ ... }}. (or simply ( ... )[@cval]).
    Other form will also implicitly work, for exemple begin[@cval ty] ... end, which is nice.
  • For injections [%inj ...] instead of %x and %(...). It's a bit more verbose, unfortunatly. I asked @alainfrisch if it was possible to use ( ... )%inj, but it's not possible.
    We could use this occasion to differenciate between injections inside a cval and injections inside a client section. It would help solve Escaped values, client values and shared section. #17.

@balat, @benozol, Did I forget anything ? @alainfrisch, do you have better suggestions ?

@alainfrisch
Copy link

I don't have any experience with writing client/server mechanism in Ocsigen, so I cannot really comment.

In order to mark "sections" of code, you could also use extension nodes or attributes as delimiters. Instead of [%%client ...], you could do:

[%%client]
....
[%%both]

This could be more robust w.r.t. other syntactic tools, since it would make the content of the section appear in the normal stream of structure items, not nested under the extension node.

For injection: if this is syntactically a unary prefix operator, did you consider using an actual operator symbol (e.g. "!!" or "~~")?

@Drup
Copy link
Member Author

Drup commented Apr 15, 2014

I prefer to have explicit delimiters for sections. And I really like let%server, so we will need to have [%server ... ] anyway. I don't think it's going to be that much of an issue with other syntax extensions, since the code modification done by eliom is minimal. Maybe we can have both with another syntax, like [%%server_section] buh meh.

Indeed, we could use an operator, but the potential of breaking something else is extremely high, so I'm not very fond of it.

@alainfrisch
Copy link

The operator could be (re)defined by the user, as is:

[%%ocsigen.injection "~~"]

This would give a way to resolve clashes locally.

@Drup
Copy link
Member Author

Drup commented Apr 15, 2014

That's an interesting solution. We could use ~% by default to have minimal modification with the current state, which is nice.

@vasilisp vasilisp closed this as completed Feb 3, 2016
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

3 participants