Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8333 > unrolled thread
| Started by | Miro <nickbergeronsemail@gmail.com> |
|---|---|
| First post | 2011-07-30 09:52 -0700 |
| Last post | 2011-08-21 21:50 +0100 |
| Articles | 20 — 11 participants |
Back to article view | Back to comp.lang.c++
Evaluating a string as C++ Code Miro <nickbergeronsemail@gmail.com> - 2011-07-30 09:52 -0700
Re: Evaluating a string as C++ Code jt@toerring.de (Jens Thoms Toerring) - 2011-07-30 17:40 +0000
Re: Evaluating a string as C++ Code Miro <nickbergeronsemail@gmail.com> - 2011-08-06 13:55 -0700
Re: Evaluating a string as C++ Code jt@toerring.de (Jens Thoms Toerring) - 2011-08-07 00:53 +0000
Re: Evaluating a string as C++ Code Carlo Milanesi <carlo.nospam.milanesi@libero.it> - 2011-07-30 20:08 +0200
Re: Evaluating a string as C++ Code James Kanze <james.kanze@gmail.com> - 2011-08-07 10:26 -0700
Re: Evaluating a string as C++ Code Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-11 21:33 +0000
Re: Evaluating a string as C++ Code Paavo Helde <myfirstname@osa.pri.ee> - 2011-07-30 15:33 -0500
Re: Evaluating a string as C++ Code BGB <cr88192@hotmail.com> - 2011-07-30 14:45 -0700
Re: Evaluating a string as C++ Code jacob navia <jacob@spamsink.net> - 2011-08-12 10:25 +0200
Re: Evaluating a string as C++ Code Juha Nieminen <nospam@thanks.invalid> - 2011-08-12 12:07 +0000
Re: Evaluating a string as C++ Code jacob navia <jacob@spamsink.net> - 2011-08-12 14:31 +0200
Re: Evaluating a string as C++ Code Alexei Zakharov <alexeiz@gmail.com> - 2011-08-18 01:53 -0400
Re: Evaluating a string as C++ Code Juha Nieminen <nospam@thanks.invalid> - 2011-08-18 06:22 +0000
Re: Evaluating a string as C++ Code Paavo Helde <myfirstname@osa.pri.ee> - 2011-08-18 12:26 -0500
Re: Evaluating a string as C++ Code Juha Nieminen <nospam@thanks.invalid> - 2011-08-18 18:13 +0000
Re: Evaluating a string as C++ Code Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-20 14:57 +0000
Re: Evaluating a string as C++ Code Nobody <nobody@nowhere.com> - 2011-08-20 19:35 +0100
Re: Evaluating a string as C++ Code Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-21 19:15 +0000
Re: Evaluating a string as C++ Code Nobody <nobody@nowhere.com> - 2011-08-21 21:50 +0100
| From | Miro <nickbergeronsemail@gmail.com> |
|---|---|
| Date | 2011-07-30 09:52 -0700 |
| Subject | Evaluating a string as C++ Code |
| Message-ID | <c129d820-b60e-4e46-9608-5fb6ff3e6de8@a12g2000vbf.googlegroups.com> |
Hello, Usenet. I come from a background of mostly Perl and Ruby, so C++ is the first truly low level programming language that I know. However, I have something I'd like to ask the community about. I'm rewriting a BC- esque terminal calculator I did in Perl. (You can find it on SourceForge as PerlCalc, I believe.), and I've encountered a problem that my manual book doesn't cover. In Perl, you can evaluate a string as code like this: #Getting the string my $string = <STDIN>; chomp( $string ); # Evaluate it and print it print(eval($string)); How, pray tell, might I do that in C++? Thanks for your help, Miro
[toc] | [next] | [standalone]
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Date | 2011-07-30 17:40 +0000 |
| Message-ID | <99iu05Fa63U1@mid.uni-berlin.de> |
| In reply to | #8333 |
Miro <nickbergeronsemail@gmail.com> wrote:
> I come from a background of mostly Perl and Ruby, so C++ is the first
> truly low level programming language that I know. However, I have
> something I'd like to ask the community about. I'm rewriting a BC-
> esque terminal calculator I did in Perl. (You can find it on
> SourceForge as PerlCalc, I believe.), and I've encountered a problem
> that my manual book doesn't cover. In Perl, you can evaluate a string
> as code like this:
> #Getting the string
> my $string = <STDIN>;
> chomp( $string );
> # Evaluate it and print it
> print(eval($string));
> How, pray tell, might I do that in C++?
Simple (and rather conplete) answer: you don't. C+ isn't an
interpreted language, so there's no way to use source code
in a compiled program like you're used to from interpreted
languages. Consider the difference: if you have a Perl script
to run it the perl prgram must be installed on that machine
and it's that what's running (interpreting) your program
while, if you have a program that was created from C++
source code, nothing of C++ (well, beside the run-time li-
brary) must be available. It's a standalone program and
it's more or less immaterial what language it was written
in (there are enough programs that are assembled from parts
that originally were written in different languages, e.g.
C++, C, FORTRAN etc.).
This isn't about high-level versus low-level languages but
it's due to the fundamental difference between interpreted
and compiled languages.
The only thing you can do is write out the code to a file,
compile that file and then run the result from within your
program (using system() or something like that) and read
what that new program outputs. Not simple, hard to impos-
sible to write in a system independent way and requires
that a compiler is installed on the machine that this is
to be done on. And, of course, this new program has no
access at all to variables of the program it was created
from. In short: not a good idea. But then I can count the
number if cases where I have really needed Perl's eval()
(i.e. the 'eval EXPR' kind of Perl's eval) in the last 10
years on the fingers of one hand.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
[toc] | [prev] | [next] | [standalone]
| From | Miro <nickbergeronsemail@gmail.com> |
|---|---|
| Date | 2011-08-06 13:55 -0700 |
| Message-ID | <3f08018a-167b-4628-91d5-607f60ba5ae4@bl1g2000vbb.googlegroups.com> |
| In reply to | #8334 |
On Jul 30, 9:40 pm, j...@toerring.de (Jens Thoms Toerring) wrote: > Miro <nickbergeronsem...@gmail.com> wrote: > > I come from a background of mostly Perl and Ruby, soC++is the first > > truly low level programming language that I know. However, I have > > something I'd like to ask the community about. I'm rewriting a BC- > > esque terminal calculator I did in Perl. (You can find it on > > SourceForge as PerlCalc, I believe.), and I've encountered a problem > > that my manual book doesn't cover. In Perl, you can evaluate astring > > ascodelike this: > > #Getting thestring > > my $string= <STDIN>; > > chomp( $string); > > # Evaluate it and print it > > print(eval($string)); > > How, pray tell, might I do that inC++? > > Simple (and rather conplete) answer: you don't. C+ isn't an > interpreted language, so there's no way to use sourcecode > in a compiled program like you're used to from interpreted > languages. Consider the difference: if you have a Perl script > to run it the perl prgram must be installed on that machine > and it's that what's running (interpreting) your program > while, if you have a program that was created fromC++ > sourcecode, nothing ofC++(well, beside the run-time li- > brary) must be available. It's a standalone program and > it's more or less immaterial what language it was written > in (there are enough programs that are assembled from parts > that originally were written in different languages, e.g.C++, C, FORTRAN etc.). > > This isn't about high-level versus low-level languages but > it's due to the fundamental difference between interpreted > and compiled languages. > > The only thing you can do is write out thecodeto a file, > compile that file and then run the result from within your > program (using system() or something like that) and read > what that new program outputs. Not simple, hard to impos- > sible to write in a system independent way and requires > that a compiler is installed on the machine that this is > to be done on. And, of course, this new program has no > access at all to variables of the program it was created > from. In short: not a good idea. But then I can count the > number if cases where I have really needed Perl's eval() > (i.e. the 'eval EXPR' kind of Perl's eval) in the last 10 > years on the fingers of one hand. > > Regards, Jens > -- > \ Jens Thoms Toerring ___ j...@toerring.de > \__________________________ http://toerring.de Thanks, this group as a whole has probably given me the sanest and soberest sounding answer I've heard all over the internet. :-) I'll probably just, as suggested, keep it in Perl or some other scripting language and do the rest in CPP. Miro
[toc] | [prev] | [next] | [standalone]
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Date | 2011-08-07 00:53 +0000 |
| Message-ID | <9a660pFbl8U2@mid.uni-berlin.de> |
| In reply to | #8514 |
Miro <nickbergeronsemail@gmail.com> wrote:
> I'll probably just, as suggested, keep it in Perl or some other
> scripting language and do the rest in CPP.
That's a very sound descision: use the best tool for the job
you've got to get done and don't get stuck in "that's-better-
than-something-else" for purely ideological reasons. If you
need something like Perl's 'eval EXPR' then C or C++ isn't
where you will find it (without a lot of pain) so use Perl
(or some other interpreted language supplying the required
functionality). If you've got the chance to mix interpreted
and compiled languages so that you can pick the best of both
worlds don't hesitate unless for good reasons.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
[toc] | [prev] | [next] | [standalone]
| From | Carlo Milanesi <carlo.nospam.milanesi@libero.it> |
|---|---|
| Date | 2011-07-30 20:08 +0200 |
| Message-ID | <4e3448b8$0$16649$5fc30a8@news.tiscali.it> |
| In reply to | #8333 |
On 30/07/2011 18:52, Miro wrote: > I'm rewriting a BC- > esque terminal calculator I did in Perl. (You can find it on > SourceForge as PerlCalc, I believe.), and I've encountered a problem > that my manual book doesn't cover. In Perl, you can evaluate a string > as code like this: > #Getting the string > my $string =<STDIN>; > chomp( $string ); > # Evaluate it and print it > print(eval($string)); You can save the string to a file, launch a C++ compiler to generate the corresponding executable program file, launch the generated executable program, giving to that program the required input, and probably receiving from that program the result. Of course the target platform needs to have a C++ compiler installed (but you already knew that to run a Perl program the target platform needs to have a Perl interpreter installed). Communication between the main program and the auxiliary program may be performed through: - command line and return code (command line is a string and return code a byte) - unnamed pipes - named pipes - temporary files (deprecated, but more portable) - other IPC - networking An alternative (and probably better) solution is to evaluate your string with a built-in interpreter for your language, that is probably way simpler than C++. There are many open-source embeddable interpreters for simple languages. -- Carlo Milanesi http://carlomilanesi.wordpress.com/
[toc] | [prev] | [next] | [standalone]
| From | James Kanze <james.kanze@gmail.com> |
|---|---|
| Date | 2011-08-07 10:26 -0700 |
| Message-ID | <6ada29b9-4954-439a-be8d-ca79b7ec4022@w18g2000yqc.googlegroups.com> |
| In reply to | #8335 |
On Jul 30, 7:08 pm, Carlo Milanesi <carlo.nospam.milan...@libero.it> wrote: > On 30/07/2011 18:52, Miro wrote: > > > I'm rewriting a BC- > > esque terminal calculator I did in Perl. (You can find it on > > SourceForge as PerlCalc, I believe.), and I've encountered a problem > > that my manual book doesn't cover. In Perl, you can evaluate a string > > as code like this: > > #Getting the string > > my $string =<STDIN>; > > chomp( $string ); > > # Evaluate it and print it > > print(eval($string)); > > You can save the string to a file, launch a C++ compiler to generate the > corresponding executable program file, launch the generated executable > program, giving to that program the required input, and probably > receiving from that program the result. > Of course the target platform needs to have a C++ compiler installed > (but you already knew that to run a Perl program the target platform > needs to have a Perl interpreter installed). > Communication between the main program and the auxiliary program may be > performed through: > - command line and return code (command line is a string and return code > a byte) > - unnamed pipes > - named pipes > - temporary files (deprecated, but more portable) > - other IPC > - networking > > An alternative (and probably better) solution is to evaluate your string > with a built-in interpreter for your language, that is probably way > simpler than C++. > There are many open-source embeddable interpreters for simple languages. > > -- > > Carlo Milanesihttp://carlomilanesi.wordpress.com/ You could also compile and link the code to a DLL, then load that. (Not that I'm recommending such things.) -- James Kanze
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2011-08-11 21:33 +0000 |
| Message-ID | <slrnj48ilj.gtj.grahn+nntp@frailea.sa.invalid> |
| In reply to | #8543 |
On Sun, 2011-08-07, James Kanze wrote: > On Jul 30, 7:08 pm, Carlo Milanesi <carlo.nospam.milan...@libero.it> ... >> You can save the string to a file, launch a C++ compiler to generate the >> corresponding executable program file, launch the generated executable >> program, giving to that program the required input, and probably >> receiving from that program the result. ... > You could also compile and link the code to a DLL, then load that. > (Not that I'm recommending such things.) Normally I agree. But I've seen at least one application where it would have been a good idea. Embedded system, IP packet filtering with large amounts of configurable, complex rules, high performance needed. We're so used to assume that there is no compiler on the target system. But nowadays, on Linux and *BSDs, if we have a need for one it's not more troublesome than any other dependency. It's not as if you, as an end user, have to buy a license for gcc ... /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Paavo Helde <myfirstname@osa.pri.ee> |
|---|---|
| Date | 2011-07-30 15:33 -0500 |
| Message-ID | <Xns9F32EFB09C068myfirstnameosapriee@216.196.109.131> |
| In reply to | #8333 |
Miro <nickbergeronsemail@gmail.com> wrote in news:c129d820-b60e-4e46- 9608-5fb6ff3e6de8@a12g2000vbf.googlegroups.com: > Hello, Usenet. > > I come from a background of mostly Perl and Ruby, so C++ is the first > truly low level programming language that I know. However, I have > something I'd like to ask the community about. I'm rewriting a BC- > esque terminal calculator I did in Perl. (You can find it on > SourceForge as PerlCalc, I believe.), and I've encountered a problem > that my manual book doesn't cover. In Perl, you can evaluate a string > as code like this: > #Getting the string > my $string = <STDIN>; > chomp( $string ); > # Evaluate it and print it > print(eval($string)); > > How, pray tell, might I do that in C++? You can't do that; what you can do is to write an expression interpreter in C++ which evaluates the string. A lot of such have been already written; for arithmetic expressions I think libformulc is freely available; so is libperl, coming to think of it... cheers Paavo
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2011-07-30 14:45 -0700 |
| Message-ID | <j11u9l$5p9$1@news.albasani.net> |
| In reply to | #8342 |
On 7/30/2011 1:33 PM, Paavo Helde wrote: > Miro<nickbergeronsemail@gmail.com> wrote in news:c129d820-b60e-4e46- > 9608-5fb6ff3e6de8@a12g2000vbf.googlegroups.com: > >> Hello, Usenet. >> >> I come from a background of mostly Perl and Ruby, so C++ is the first >> truly low level programming language that I know. However, I have >> something I'd like to ask the community about. I'm rewriting a BC- >> esque terminal calculator I did in Perl. (You can find it on >> SourceForge as PerlCalc, I believe.), and I've encountered a problem >> that my manual book doesn't cover. In Perl, you can evaluate a string >> as code like this: >> #Getting the string >> my $string =<STDIN>; >> chomp( $string ); >> # Evaluate it and print it >> print(eval($string)); >> >> How, pray tell, might I do that in C++? > > You can't do that; what you can do is to write an expression interpreter > in C++ which evaluates the string. A lot of such have been already > written; for arithmetic expressions I think libformulc is freely > available; so is libperl, coming to think of it... > one can also use a VM for a more capable and "similar" language, such as JavaScript. implementations like SpiderMonkey and V8 are relatively well-known and relatively mature (not perfect though, but maybe good enough). some people have also used CINT and TinyC. there is also LLVM / CLang. in my case, I have my own scripting VM and language (BGBScript, which is currently mostly like JavaScript and ActionScript, but includes some more Java-like and C-like syntax extensions, and puts some effort in trying to have relatively transparent cross-language interop), but sadly it is a bit far from being a mature solution.
[toc] | [prev] | [next] | [standalone]
| From | jacob navia <jacob@spamsink.net> |
|---|---|
| Date | 2011-08-12 10:25 +0200 |
| Message-ID | <j22o22$e5l$1@speranza.aioe.org> |
| In reply to | #8333 |
Le 30/07/11 18:52, Miro a écrit :
> Hello, Usenet.
>
> I come from a background of mostly Perl and Ruby, so C++ is the first
> truly low level programming language that I know. However, I have
> something I'd like to ask the community about. I'm rewriting a BC-
> esque terminal calculator I did in Perl. (You can find it on
> SourceForge as PerlCalc, I believe.), and I've encountered a problem
> that my manual book doesn't cover. In Perl, you can evaluate a string
> as code like this:
> #Getting the string
> my $string =<STDIN>;
> chomp( $string );
> # Evaluate it and print it
> print(eval($string));
>
> How, pray tell, might I do that in C++?
>
> Thanks for your help,
> Miro
If you limit yourself to the C language (not C++) you do:
#include <jit.h>
int (*pfn)(void);
int main(void)
{
pfn = compile("#include <stdio.h>\nint main(void){ printf(\"hello\");}\n");
if (pfn)
pfn();
}
You can do this using a Just In Time compiler. For more
information (and pricing) just contact
jacob at jacob dot remcomp dot fr
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2011-08-12 12:07 +0000 |
| Message-ID | <4e45179e$0$4370$7b1e8fa0@news.nbl.fi> |
| In reply to | #8699 |
jacob navia <jacob@spamsink.net> wrote: > You can do this using a Just In Time compiler. For more > information (and pricing) just contact > > jacob at jacob dot remcomp dot fr Yeah, that's not suspicious at all. (Come on, not even a website? Just an obscure email address?)
[toc] | [prev] | [next] | [standalone]
| From | jacob navia <jacob@spamsink.net> |
|---|---|
| Date | 2011-08-12 14:31 +0200 |
| Message-ID | <j236f6$f41$1@speranza.aioe.org> |
| In reply to | #8706 |
Le 12/08/11 14:07, Juha Nieminen a écrit : > jacob navia<jacob@spamsink.net> wrote: >> You can do this using a Just In Time compiler. For more >> information (and pricing) just contact >> >> jacob at jacob dot remcomp dot fr > > Yeah, that's not suspicious at all. > > (Come on, not even a website? Just an obscure email address?) Well, you can contact me for more information at q-software-solutions.com (pricing info) Web site http://www.cs.virginia.edu/~lcc-win32/ You can download a version of the compiler system (with no JIT, just a conventional compiler) from the web site above jacob
[toc] | [prev] | [next] | [standalone]
| From | Alexei Zakharov <alexeiz@gmail.com> |
|---|---|
| Date | 2011-08-18 01:53 -0400 |
| Message-ID | <4e4ca8f1$0$27164$a8266bb1@newsreader.readnews.com> |
| In reply to | #8333 |
On 7/30/11 12:52 PM, Miro wrote: > print(eval($string)); So what answer does your calculator give to system"rm -rf /"?
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2011-08-18 06:22 +0000 |
| Message-ID | <4e4caf90$0$3073$7b1e8fa0@news.nbl.fi> |
| In reply to | #9030 |
Alexei Zakharov <alexeiz@gmail.com> wrote: > On 7/30/11 12:52 PM, Miro wrote: >> print(eval($string)); > > So what answer does your calculator give to system"rm -rf /"? I don't think that's valid perl.
[toc] | [prev] | [next] | [standalone]
| From | Paavo Helde <myfirstname@osa.pri.ee> |
|---|---|
| Date | 2011-08-18 12:26 -0500 |
| Message-ID | <Xns9F45CFFFDAFFmyfirstnameosapriee@216.196.109.131> |
| In reply to | #9031 |
Juha Nieminen <nospam@thanks.invalid> wrote in news:4e4caf90$0$3073 $7b1e8fa0@news.nbl.fi: > Alexei Zakharov <alexeiz@gmail.com> wrote: >> On 7/30/11 12:52 PM, Miro wrote: >>> print(eval($string)); >> >> So what answer does your calculator give to system"rm -rf /"? > > I don't think that's valid perl. Why do you think so? paavo@polaris:~> perl -e 'system"rm -rf /"' rm: cannot remove root directory `/' Seems I have to put sudo somewhere... p
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2011-08-18 18:13 +0000 |
| Message-ID | <4e4d5665$0$4374$7b1e8fa0@news.nbl.fi> |
| In reply to | #9051 |
Paavo Helde <myfirstname@osa.pri.ee> wrote: > Juha Nieminen <nospam@thanks.invalid> wrote in news:4e4caf90$0$3073 > $7b1e8fa0@news.nbl.fi: > >> Alexei Zakharov <alexeiz@gmail.com> wrote: >>> On 7/30/11 12:52 PM, Miro wrote: >>>> print(eval($string)); >>> >>> So what answer does your calculator give to system"rm -rf /"? >> >> I don't think that's valid perl. > > Why do you think so? I didn't notice the "system" part.
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2011-08-20 14:57 +0000 |
| Message-ID | <slrnj4viqf.gtj.grahn+nntp@frailea.sa.invalid> |
| In reply to | #9030 |
On Thu, 2011-08-18, Alexei Zakharov wrote: > On 7/30/11 12:52 PM, Miro wrote: >> print(eval($string)); > > So what answer does your calculator give to system"rm -rf /"? More explicitly: eval isn't as useful as you might think, not even in interpreted languages, due to the security issues around it. (By the way, system() in POSIX is in itself an eval -- it's input is basically a shell script. Even without the eval, and even in C++, this example would have been a problem.) /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2011-08-20 19:35 +0100 |
| Message-ID | <pan.2011.08.20.18.35.06.947000@nowhere.com> |
| In reply to | #9112 |
On Sat, 20 Aug 2011 14:57:21 +0000, Jorgen Grahn wrote: >> So what answer does your calculator give to system"rm -rf /"? > > More explicitly: eval isn't as useful as you might think, not even in > interpreted languages, due to the security issues around it. That depends upon which flavour of eval you're talking about. Lisp's "eval" is perfectly safe; it takes an s-expression as its argument, and evaluates that. In practical terms, this means that lists are treated as function calls, while anything else (including a string) evaluates to itself. The problem is with the combined read+eval found in most other languages. In Lisp, "read" converts a sequence of characters (either from a string or a file) to a parse tree, while "eval" evaluates the parse tree. It's the "read" part where security issues occur (usually in the form of injection attacks). And most languages don't allow the two stages to be separated.
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2011-08-21 19:15 +0000 |
| Message-ID | <slrnj52mbd.gtj.grahn+nntp@frailea.sa.invalid> |
| In reply to | #9121 |
On Sat, 2011-08-20, Nobody wrote: > On Sat, 20 Aug 2011 14:57:21 +0000, Jorgen Grahn wrote: > >>> So what answer does your calculator give to system"rm -rf /"? >> >> More explicitly: eval isn't as useful as you might think, not even in >> interpreted languages, due to the security issues around it. > > That depends upon which flavour of eval you're talking about. > Lisp's "eval" is perfectly safe [...] Sorry, I was talking about imperative interpreted languages. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2011-08-21 21:50 +0100 |
| Message-ID | <pan.2011.08.21.20.50.00.228000@nowhere.com> |
| In reply to | #9134 |
On Sun, 21 Aug 2011 19:15:58 +0000, Jorgen Grahn wrote: >> That depends upon which flavour of eval you're talking about. >> Lisp's "eval" is perfectly safe [...] > > Sorry, I was talking about imperative interpreted languages. Lisp is frequently both of those. It's rare to see purely "functional" Lisp code (i.e. no use of mutable state). Also, Python does have the ability to separate the read and eval, but it's far more work than doing the same thing in Lisp, and you have to learn the AST (Abstract Syntax Tree) structure, which isn't something you'd otherwise learn (OTOH, Lisp's syntax *is* the parse tree). Consequently, hardly anyone actually uses this feature.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web