Re: [Csnd] Syntax for #include
Date | 2018-06-10 16:31 |
From | John |
Subject | Re: [Csnd] Syntax for #include |
In the light of comments I have left #include exactly like it was but introduced a new preprocessor option #read #read is like #include except: (a) it must use delimiter double quote like a string, and (b) the string is subject to macro expansion This maintains backward compatability and gives a way for macros to be used generally in reading file names. ==John ffitch Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2018-06-10 17:07 |
From | Dave Seidel |
Subject | Re: [Csnd] Syntax for #include |
Thanks, John, this makes sense. Though perhaps you might consider using a more standard name for the directive, such as "import"? On Sun, Jun 10, 2018, 11:32 AM John <jpff@codemist.co.uk> wrote: In the light of comments I have left #include exactly like it was but |
Date | 2018-06-10 17:18 |
From | John ff |
Subject | Re: [Csnd] Syntax for #include |
I did suggest import but that clashed with csound7 llans
Sent from Blue
On 10 Jun 2018, at 17:07, Dave Seidel <dave.seidel@gmail.com> wrote:
|
Date | 2018-06-10 18:14 |
From | Michael Gogins |
Subject | Re: [Csnd] Syntax for #include |
I suggest "#include2" or "#includestr" so the relation with and difference from "#include" is more clear. Regards, Mike On Sun, Jun 10, 2018, 12:18 John ff <jpff@codemist.co.uk> wrote:
|
Date | 2018-06-10 18:29 |
From | Dave Seidel |
Subject | Re: [Csnd] Syntax for #include |
I like #includestr On Sun, Jun 10, 2018, 1:15 PM Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2018-06-10 20:11 |
From | Steven Yi |
Subject | Re: [Csnd] Syntax for #include |
Again, I'll ask: why aren't you all using the INCDIR enviroment variable to define where to #include files from? Or another question: what does this feature give us for benefits versus the maintenance and pedagogical costs? If there's a problem with INCDIR and the current method for file inclusion, then I'd rather first see if that can be addressed with the current facilities, which I do not think has been considered in this thread. What I see here is a new solution to a problem that already had a solution. I think it's a real burden to add more code/features when there's already a valid solution that covers the use cases brought up on this list so far. I'd also mention that most import/include systems I know do not offer such features and everyone gets on just fine by setting a list of source paths and/or using #ifdefs to conditionally include from specific locations. (That said, if someone has an example where file inclusion is done as proposed in other languages/systems, it'd be useful to understand here.) On Sun, Jun 10, 2018 at 10:29 AM Dave Seidel |
Date | 2018-06-11 01:13 |
From | Dave Seidel |
Subject | Re: [Csnd] Syntax for #include |
INCDIR is not a good solution for my use-case, at least. I would like to have a number of "modules" (table definitions and other orchestra code) that use consistent naming, and would like to be able to specify on the command-line which one to load. Specifically, I have a set of tuning tables for a MIDI keyboard/controller-driven piece, and when I load it up, I want to be able to specify the tuning. I don't want to have to put a bunch of small files each into a separate subdirectory -- in fact, I would like to have them all in the *same* subdirectory. For this scenario, I would like to be able to use something like "--omacro:SCALE=xxx" to specify what gets loaded for a particular run, and then within the CSD, "#include $xxx.inc". I don't necessarily expect to get exactly what I want, but INCDIR would be rather clumsy in this case, IMO. On Sun, Jun 10, 2018 at 3:11 PM Steven Yi <stevenyi@gmail.com> wrote: Again, I'll ask: why aren't you all using the INCDIR enviroment
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
|
Date | 2018-06-11 02:11 |
From | Steven Yi |
Subject | Re: [Csnd] Syntax for #include |
So right now you could organize your code into something like this directory structure: project_dir + scale0 + scale.inc + scale1 + scale.inc use this include: #include "scale.inc" and set it on commandline using --env:INCDIR+=scale0 for example. But you're saying you'd rather have: project_dir + project.csd + scale0.inc + scale1.inc use this include: #include "$SCALE.inc" and use a commandline of: --omacro:SCALE=scale0 I can see how the latter has some elegance to it but I'd say the first is clear enough. It's fine that we have differences of opinion on if this is clumsy or not though. The former does work today which is one thing it has going for it. Another option is to have multiple CSD files, one for each configuration. You could have something like: project_dir + scale0.csd + scale1.csd + lib + main.orc + scale0.orc + scale1.orc where scale0.csd is a very small CSD that has: #include "lib/scale0.orc" #include "lib/main.orc" and scale1.csd has: #include "lib/scale1.orc" #include "lib/main.orc" Another possibility is the scale specific code could be in the CSD and just the main.orc is included, something like: project_dir + scale0.csd + scale1.csd + main.orc These options require no special commandline flags necessary and everything for the exact configuration you want is set, you just choose which CSD to run. There's also using #ifdefs with something like: #ifdef SCALE0 #include "scale0.inc" #endif etc. which is not the nicest I think. Anyways, there are some options in today's Csound for choosing what code to use as part of a project. I'd mention that Python has importlib for dynamic module import, but something like this not possible with CPP (C Preprocessor) as far as I know, and I think we could get on just fine without it. On Sun, Jun 10, 2018 at 5:13 PM Dave Seidel |
Date | 2018-06-11 02:24 |
From | thorin kerr |
Subject | Re: [Csnd] Syntax for #include |
I'd have thought if macros were expanded prior to processing #include statements, then a lot of this would be solved. Just put the delimiters in your definition and call. E.g. Daves use case: --omacro:Scale=Myscale' #include '$ Expanded = #include 'Myscale' Similarly, if you go back to the original poster's issue: #include #define PATHH #'/path/to/somewere# #include $PATHH/file1.txt' #include $PATHH/file2.txt' #include $PATHH/file3.txt' -- Thorin On Mon, 11 Jun. 2018, 10:13 am Dave Seidel, <dave.seidel@gmail.com> wrote:
|
Date | 2018-06-11 13:20 |
From | John ff |
Subject | Re: [Csnd] Syntax for #include |
That would require a redesign of the macro system equivalent to what did with #read (or #includestr?) and has the same compatibility issue. Sent from TypeApp On Jun 11, 2018, 02:26, at 02:26, thorin kerr |