Talk:Compiler/Simple file inclusion pre processor: Difference between revisions

(Two preprocessor tasks)
 
(4 intermediate revisions by 3 users not shown)
Line 1:
===wrongWhat language=is the task?==
Currently, there's no specific feature set required of a preprocessor. So how would we distinguish between an adequate and inadequate implementation? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 15:43, 22 July 2022 (UTC)
 
:Good point - I've split the task description (which I hope isn't too TLDR) into sections, including one on the minimum requirements. --[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 19:51, 22 July 2022 (UTC).
 
==wrong language==
This task would probably be more useful and help compare different languages better (the point of this site) if it handled the same syntax used by [[Compiler/Sample_programs]], rather than ALGOL 68 processes ALGOL 68, C processes C, PL/1 processes PL/1, Phix processes Phix, etc. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 17:35, 6 June 2021 (UTC)
 
Line 40 ⟶ 45:
:::Also, I doubt that a C pre-processor written in anything but C would get much use for anything other than bootstrapping... --[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 21:42, 6 June 2021 (UTC)
I believe our sample language could use one line: #include "file" and #define call value. Usage could be:
<pre>
~~ Header.h ~~
#define area(h, w) h*w
Line 48 ⟶ 54:
#define height() 6
area = #area(height, width)#;
</pre>
 
yielding code output of:
<pre>
area = 6*5;
</pre>
 
Or:
<pre>
/* Include Header.h */
/* Define area(h, w) as h*w */
Line 60 ⟶ 68:
/* Use area, height, and width */
area = 6*5;
</pre>
 
This should be in addition to the existing preprocessor definition as both are useful demonstrations. This new one providing identical language support to our sample language in multiple source languages.
 
:Hi Jwells - thanks for considering this Task. When I created it I thought it would be a way to compare how different languages (could) handle file inclusion (not that all do). The difficulty of handling e.g. PL1's %Include compared to e.g. C's #include seemed an interesting way of comparing languages. I also thought having a set of file-inclusion pre-processors available on RC would make it easier for the solutions to other tasks to use file inclusion for common things. That seemed a good idea at the time...
 
:Whilst the task isn't intended to be "Implement the C pre-processor in your language", for languages that don't have their own specific syntax, that is an option for this task. I see from your User page that you are doing stuff in Kotlin - which I imagine doesn't have in built file inclusion - if you wanted to implement a C-style #include in Kotlin, that would be nice.
 
:I was hoping to keep the task reasonably simple so it didn't require implementation of #define or #if-#endif etc., however I agree they are useful things to have. I gather that the C pre-processor is used in in some current Fortran programming, for example. Maybe implementing a macro processor should be a task too ?
 
:BTW, you should probably sign your comments - add <nowiki>--~~~~</nowiki> (without the "nowiki" tags) to the end of the comment.
 
:--[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 12:23, 22 May 2022 (UTC)
3,021

edits