Dart, how to parse user string into functional dart code?
Asked Answered
R

1

6

is it possible to parse in a user entered string, say from a text area, and then incorporate it into a dart function which you can then run, without having to post it back to the server? I guess I'm looking for a dart eval equivalent.

Radiometeorograph answered 16/9, 2013 at 14:29 Comment(0)
A
8

There is no notion of eval in Dart, and it is not possible to dynamically build code. You can run code in a different isolate using spawnUri (see http://api.dartlang.org/docs/releases/latest/dart_isolate.html). When not running in the Dartium browser, note that the Dart code needs to be compiled to JavaScript using dart2js. The site http://try.dartlang.org/ does all that.

Some time in the future Dart might get mirror builders which can be used for "programs to extend and modify themselves" (citation from last paragraph in https://www.dartlang.org/articles/reflection-with-mirrors/).

Antepast answered 17/9, 2013 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.