Re: AST like coding syntax. Easy upgrade!

2015-09-07 Thread Dmitry Olshansky via Digitalmars-d
On 07-Sep-2015 08:25, anonymous wrote: On Monday 07 September 2015 02:24, Idan Arye wrote: That's not considered as syntax check - that's an earlier stage of the compilation process called "lexical analysis"(https://en.wikipedia.org/wiki/Lexical_analysis) From the Wikipedia article: "a

Re: AST like coding syntax. Easy upgrade!

2015-09-07 Thread Sergei Nosov via Digitalmars-d
On Monday, 7 September 2015 at 02:50:06 UTC, Adam D. Ruppe wrote: On Sunday, 6 September 2015 at 23:33:17 UTC, Walter Bright wrote: I'd always thought Javascript was an ideal extension language for a text editor. Well, I don't think *ideal*, but indeed, it wouldn't be bad. C'mon, kind sirs!

Re: AST like coding syntax. Easy upgrade!

2015-09-07 Thread Jacob Carlborg via Digitalmars-d
On 2015-09-06 21:32, Prudence wrote: template X(Y) { string X = Y.stringof; } auto s = X({int 3;}) Of course, doesn't work!! You might be interested in this [1]. [1] http://wiki.dlang.org/DIP50 -- /Jacob Carlborg

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Prudence via Digitalmars-d
On Sunday, 6 September 2015 at 20:22:23 UTC, Zoadian wrote: On Sunday, 6 September 2015 at 19:32:58 UTC, Prudence wrote: template X(Y) { string X = Y.stringof; } [...] as you'd have to write a parser for other languages why not just use strings? you can already do this: template

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Adam D. Ruppe via Digitalmars-d
On Monday, 7 September 2015 at 00:34:20 UTC, Idan Arye wrote: Compare it to Ruby's heredoc, where the chosen terminator string can be used as an hint(https://github.com/joker1007/vim-ruby-heredoc-syntax). Or D's heredoc strings, yes, we have them too: http://dlang.org/lex.html (search for

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread anonymous via Digitalmars-d
On Monday 07 September 2015 02:24, Idan Arye wrote: > That's not considered as syntax check - that's an earlier stage > of the compilation process called "lexical > analysis"(https://en.wikipedia.org/wiki/Lexical_analysis) >From the Wikipedia article: "a lexer is generally combined with a

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread bitwise via Digitalmars-d
On Sunday, 6 September 2015 at 22:37:16 UTC, cym13 wrote: On Sunday, 6 September 2015 at 21:16:18 UTC, Prudence wrote: [...] There already is a kind of "code string": interpret(q{ var a = 2; var b += a; }); It doesn't do any kind of syntax check, but there again

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread anonymous via Digitalmars-d
On Monday 07 September 2015 00:37, cym13 wrote: > There already is a kind of "code string": > > interpret(q{ > var a = 2; > var b += a; > }); > > It doesn't do any kind of syntax check, but there again how do > you want to have syntax check for any language? The D

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Zoadian via Digitalmars-d
On Sunday, 6 September 2015 at 19:32:58 UTC, Prudence wrote: template X(Y) { string X = Y.stringof; } [...] as you'd have to write a parser for other languages why not just use strings? you can already do this: template X(string Y) { enum X = Y; } auto s = X!q{int 3;};

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Prudence via Digitalmars-d
On Sunday, 6 September 2015 at 20:38:44 UTC, Adam D. Ruppe wrote: On Sunday, 6 September 2015 at 20:22:23 UTC, Zoadian wrote: obviously X has to be a compiletime js->d compiler. Just a fun fact: my script.d's interpreter is itself CTFEable in modern dmd! import arsd.script; void main() {

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread cym13 via Digitalmars-d
On Sunday, 6 September 2015 at 23:00:21 UTC, bitwise wrote: On Sunday, 6 September 2015 at 22:37:16 UTC, cym13 wrote: On Sunday, 6 September 2015 at 21:16:18 UTC, Prudence wrote: [...] There already is a kind of "code string": interpret(q{ var a = 2; var b += a;

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread cym13 via Digitalmars-d
On Sunday, 6 September 2015 at 23:48:30 UTC, cym13 wrote: On Sunday, 6 September 2015 at 23:40:58 UTC, anonymous wrote: On Monday 07 September 2015 00:37, cym13 wrote: There already is a kind of "code string": interpret(q{ var a = 2; var b += a; }); It doesn't

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread cym13 via Digitalmars-d
On Sunday, 6 September 2015 at 23:40:58 UTC, anonymous wrote: On Monday 07 September 2015 00:37, cym13 wrote: There already is a kind of "code string": interpret(q{ var a = 2; var b += a; }); It doesn't do any kind of syntax check, but there again how do you

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Idan Arye via Digitalmars-d
On Sunday, 6 September 2015 at 23:40:58 UTC, anonymous wrote: On Monday 07 September 2015 00:37, cym13 wrote: There already is a kind of "code string": interpret(q{ var a = 2; var b += a; }); It doesn't do any kind of syntax check, but there again how do you

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Adam D. Ruppe via Digitalmars-d
On Sunday, 6 September 2015 at 23:33:17 UTC, Walter Bright wrote: I'd always thought Javascript was an ideal extension language for a text editor. Well, I don't think *ideal*, but indeed, it wouldn't be bad. And my little thing isn't quite JS, I borrow some ideas from D too. So it has string

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Adam D. Ruppe via Digitalmars-d
On Sunday, 6 September 2015 at 21:16:18 UTC, Prudence wrote: Yeah, but wouldn't it be so much nicer? (and probably debuggable inline) interpret({ var a = 5; a += 2; a; } Not really because that already more-or-less works today (add a q before that { and it will compile). The

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Walter Bright via Digitalmars-d
On 9/6/2015 1:38 PM, Adam D. Ruppe wrote: jsvar.d and script.d can be found here: https://github.com/adamdruppe/arsd I'd always thought Javascript was an ideal extension language for a text editor.

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Adam D. Ruppe via Digitalmars-d
On Sunday, 6 September 2015 at 20:22:23 UTC, Zoadian wrote: obviously X has to be a compiletime js->d compiler. Just a fun fact: my script.d's interpreter is itself CTFEable in modern dmd! import arsd.script; void main() { // script.d is similar to but not identical to javascript

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread cym13 via Digitalmars-d
On Sunday, 6 September 2015 at 21:16:18 UTC, Prudence wrote: Or, maybe better yet, have the concept of "code strings". which are strings that are suppose to be interpreted as code. This then means the compiler just has to do a syntax check for errors before it does anything else with

Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Idan Arye via Digitalmars-d
On Sunday, 6 September 2015 at 23:38:51 UTC, cym13 wrote: On Sunday, 6 September 2015 at 23:00:21 UTC, bitwise wrote: On Sunday, 6 September 2015 at 22:37:16 UTC, cym13 wrote: On Sunday, 6 September 2015 at 21:16:18 UTC, Prudence wrote: [...] There already is a kind of "code string":

AST like coding syntax. Easy upgrade!

2015-09-06 Thread Prudence via Digitalmars-d
template X(Y) { string X = Y.stringof; } auto s = X({int 3;}) Of course, doesn't work!! But having the ability to pass code that isn't contained in a string is very useful!! 1. A new code keyword, similar to alias. Can only be used as template parameters. If you are worried about