• #include

    From Mr Flibble@21:1/5 to All on Sat Mar 22 18:15:53 2025
    Hi!

    Support for the equivalent of #include has been added to "neos" the
    universal compiler that can compile any programming language:

    class source_package_import : public
    semantic_concept<source_package_import>
    {
    // types
    public:
    using data_type = neolib::string;
    // construction
    public:
    source_package_import() :
    semantic_concept{ "source.package.import", neos::language::emit_type::Infix }
    {
    }
    // emit
    public:
    bool can_fold() const override
    {
    return holds_data();
    }
    bool can_fold(const i_semantic_concept& aRhs) const override
    {
    return aRhs.name() == "source.package.name";
    }
    // emit
    protected:
    void do_fold(i_context& aContext,
    neolib::i_ref_ptr<i_semantic_concept>& aResult) override
    {
    language::source_fragment file{ data<neolib::string>() };
    file.set_imported();
    aContext.load_fragment(file);
    aContext.compiler().compile(std::move(file));
    }
    void do_fold(i_context& aContext, const i_semantic_concept& aRhs, neolib::i_ref_ptr<i_semantic_concept>& aResult) override
    {
    data<neolib::string>() = aRhs.data<neolib::i_string>();
    aResult.reset(this);
    }
    };

    /Flibble

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mikko@21:1/5 to Mr Flibble on Sun Mar 23 10:54:35 2025
    On 2025-03-22 18:15:53 +0000, Mr Flibble said:

    Support for the equivalent of #include has been added to "neos" the
    universal compiler that can compile any programming language:

    You should reconsider that. Some languages use include to compensate
    the lack of some better features for the same purpose. languages that
    have those better features don't need include and usually haven't.

    --
    Mikko

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Heathfield@21:1/5 to Mikko on Sun Mar 23 09:15:42 2025
    On 23/03/2025 08:54, Mikko wrote:

    <snip>

    Some languages use include to compensate the lack of some
    better features for the same purpose. languages that have
    those better features don't need include and usually haven't.

    If I were a Ritchie (pace, Tevye, there is no music), the VERY
    FIRST TIME a compilation failed because I forgot a header I'd
    have merged all the headers into one and then hardcoded that one
    everything.h header into the compiler itself. Problem... SOLVED.

    --
    Richard Heathfield
    Email: rjh at cpax dot org dot uk
    "Usenet is a strange place" - dmr 29 July 1999
    Sig line 4 vacant - apply within

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Damon@21:1/5 to Mikko on Sun Mar 23 07:08:05 2025
    On 3/23/25 4:54 AM, Mikko wrote:
    On 2025-03-22 18:15:53 +0000, Mr Flibble said:

    Support for the equivalent of #include has been added to "neos" the
    universal compiler that can compile any programming language:

    You should reconsider that. Some languages use include to compensate
    the lack of some better features for the same purpose. languages that
    have those better features don't need include and usually haven't.


    But since some languages use it, to compile programs in that language
    you need it.

    You also need the equivalent statement in other languages, like import.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Heathfield@21:1/5 to Richard Damon on Sun Mar 23 11:11:56 2025
    On 23/03/2025 11:08, Richard Damon wrote:
    On 3/23/25 5:15 AM, Richard Heathfield wrote:
    On 23/03/2025 08:54, Mikko wrote:

    <snip>

    Some languages use include to compensate the lack of some
    better features for the same purpose. languages that have
    those better features don't need include and usually haven't.

    If I were a Ritchie (pace, Tevye, there is no music), the VERY
    FIRST TIME a compilation failed because I forgot a header I'd
    have merged all the headers into one and then hardcoded that
    one everything.h header into the compiler itself. Problem...
    SOLVED.


    Doesn't work for user includes.

    Indeed. But if it works for stdio, stdlib, string, math, ctype
    and assert, it works all the work it has to.


    Yes, we could have the compiler auto include all the standard
    headers, but then we lose the ability to improve the backwards
    compatibility of standards that require the inclusion of a new
    header to enable new nice symbols for new features that used to
    be available to the user to use.

    I'll take the hit. :-)

    --
    Richard Heathfield
    Email: rjh at cpax dot org dot uk
    "Usenet is a strange place" - dmr 29 July 1999
    Sig line 4 vacant - apply within

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Damon@21:1/5 to Richard Heathfield on Sun Mar 23 07:08:06 2025
    On 3/23/25 5:15 AM, Richard Heathfield wrote:
    On 23/03/2025 08:54, Mikko wrote:

    <snip>

    Some languages use include to compensate the lack of some
    better features for the same purpose. languages that have
    those better features don't need include and usually haven't.

    If I were a Ritchie (pace, Tevye, there is no music), the VERY FIRST
    TIME a compilation failed because I forgot a header I'd have merged all
    the headers into one and then hardcoded that one everything.h header
    into the compiler itself. Problem... SOLVED.


    Doesn't work for user includes.

    Yes, we could have the compiler auto include all the standard headers,
    but then we lose the ability to improve the backwards compatibility of standards that require the inclusion of a new header to enable new nice
    symbols for new features that used to be available to the user to use.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mikko@21:1/5 to Richard Heathfield on Mon Mar 24 09:21:37 2025
    On 2025-03-23 09:15:42 +0000, Richard Heathfield said:

    On 23/03/2025 08:54, Mikko wrote:

    <snip>

    Some languages use include to compensate the lack of some
    better features for the same purpose. languages that have
    those better features don't need include and usually haven't.

    If I were a Ritchie (pace, Tevye, there is no music), the VERY FIRST
    TIME a compilation failed because I forgot a header I'd have merged all
    the headers into one and then hardcoded that one everything.h header
    into the compiler itself. Problem... SOLVED.

    That's the way with the standard libraries but modular programming requires something else.

    --
    Mikko

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)