Menu

#1246 load command and macro expansion

closed-fixed
nobody
None
5
2015-03-23
2013-06-07
jzman
No

I'm running gnuplot 4.6.3 on a Mac (gnuplot was installed via macports) and found the following unexpected behaviour:

When loading files with macros, it appears that macros are evaluated only up to a depth of one. Prepare the followig two .gp files

macro_test_1.gp:
set macro
macro_test="sin(x)"
func="@macro_test"

macro_test_2.gp:
plot @func

and run

load macro_test_1.gp
load macro_test_2.gp

on the interactive gnuplot prompt.

Observed behaviour: "macro_test_2.gp", line 1: invalid character @

Expected behaviour: A plot of sin(x) in the current terminal.

The same error is given by gnuplot if one puts the 'plot @func' command in the first file. Though, that is probably not expected to expand properly, since macros can not be defined and used on the same line?

Issuing a 'plot @func' on the interactive prompt works as expected.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2013-06-07

    It works as expected if you simply say
    plot @func
    directly rather than trying to load that same command from a file.
    So I agree there is a bug or strangeness shown by this test case, but it has something to do with macro expansion inside a load command rather than a more general problem with macros of depth > 1.

     
  • Ethan Merritt

    Ethan Merritt - 2013-06-28
    • status: open --> closed-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.