Thread: HyperC

  1. #46
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148

    Question

    what is the type of this string? what is its size?
    The string is a char[] null terminated array.

    should free be called?
    I believe that is a preference.

    Code:
      clear value;


  2. #47
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148

    Cool HyperC tips...

    constructing formatted strings:
    Code:
    <stdio.h>; <string.h>;
    
    @{
    
      with char ;
        string1[100]; string2[100];
      with float ;
        a = 1.0; b = 2.0; c = 3.0;
        total = 0;
      with;
      
      string1 = "a = %f, b = %f, c = %f", a, b, c;
      total = (a+b+c);
      string2 = "a+b+c = %f", total;
      
      ink [s]string1 "\n" [s]string2;
    
    
    };


  3. #48
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148

    Post example...

    Fibonacci Series:
    Code:
    <stdio.h>; <string.h>;
    @{
        int current = 0, next = 1, temp;
        ink "Enter the number of terms: "; get number;
        ink "Fibonacci Series: ";
        loop 1 to atoi(number) as i {
          ink [i]current;
          case i != atoi(number) { ink ", "; };
          temp = ( current + next );
          current = next; next = temp;
        };
    };


  4. #49
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148

    Post HyperC

    Feel free to download and try hcc.exe

    If you are wondering about a feature or have an idea on how to improve HyperC post your thoughts.

    You can find it here:

    Hyper C Compiler


  5. #50
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,271
    Quote Originally Posted by Structure
    The string is a char[] null terminated array.
    That's an incomplete answer. Remember, if you're reading input to be stored in an array, the size of the array must be known in advance, whether it is a fixed size array or a variable length array. So, what's the size of the array? What if a larger array is required to fit all the input? What if the input is too large for the array? Can the size of the array be customised with get?

    Quote Originally Posted by Structure
    I believe that is a preference
    It isn't: calling free on an array of char results in undefined behaviour. As you're building on C, this means that you must either define the behaviour, or be explicit about retaining it.

    Quote Originally Posted by Structure
    Code:
    clear value;
    This is a meaningless example. When giving examples, provide context and explain both syntax and semantics. You have this same issue in your documentation, which makes HyperC hard to understand. Ideally, provide both tutorial format documentation to guide potential users, and reference style documentation to properly document syntax and semantics.

    By the way, you should take care about reserved words: are you really intending to make get and clear reserved words? They are so commonly used.
    Last edited by laserlight; 09-14-2019 at 07:01 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #51
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148
    Ideally, provide both tutorial format documentation to guide potential users, and reference style documentation to properly document syntax and semantics.
    Obviously, I am horrible at documentation.

    Can the size of the array be customised with get?
    It will be by the end of the day.

    this means that you must either define the behaviour, or be explicit about retaining it.
    tbh, i can do whatever i want. I built it.


  7. #52
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,271
    Quote Originally Posted by Structure
    Obviously, I am horrible at documentation.
    Not saying that I'm volunteering, but one option then is to team up with someone who's better at documentation. This has the added benefit of being able to talk over stuff with someone else and hence improve your programming language.

    Quote Originally Posted by Structure
    tbh, i can do whatever i want. I built it.
    Sure, but if nobody else knows how to use the constructs of your programming language because in your arrogance as language designer you keep things to yourself, then they simply aren't going to use your programming language. If you're interested in seeing adoption, then you have to define stuff and communicate it so potential users will understand the expected semantics.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #53
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148

    Thumbs up HyperC Update Version 4.2.3

    Can the size of the array be customised with get?
    It is now required that you set the size of the array.
    i.e:
    Code:
    <stdio.h>; <string.h>;
    
    @{
      ink "Enter your name: "; 
      get name[100];
      ink "Hello " [s]name ".";
    };
    before you would use get name.
    now you define the size of the array: name[10];

    improve your programming language.
    Goals.

    interested in seeing adoption
    Possibly...

    keep things to yourself
    As far as the source goes, absolutely.

    they simply aren't going to use your programming language.
    bummer.
    Last edited by Structure; 09-15-2019 at 08:48 AM.


  9. #54
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148
    if nobody else knows how to use the constructs of your programming language
    That's what these posts are for.


  10. #55
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,271
    Quote Originally Posted by Structure View Post
    That's what these posts are for.
    You can stop misquoting me now: I wrote that in reference to your reply to me that "tbh, i can do whatever i want. I built it." when I reminded you that "calling free on an array of char results in undefined behaviour" hence you "must either define the behaviour, or be explicit about retaining it", which is just common sense: if you don't say when undefined behaviour in C is defined in HyperC, who would know?

    Furthermore, while it is alright to seek feedback for HyperC on this forum, you should be putting your actual HyperC documentation on its website, not here.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #56
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148
    You can stop misquoting me now
    oops?

    if you don't say when undefined behaviour in C is defined in HyperC
    tbh, I have no idea what this means.


  12. #57
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,271
    Quote Originally Posted by Structure
    tbh, I have no idea what this means.
    Do you understand what "undefined behaviour" means in C? It's important for HyperC since you want to build HyperC on C. If you were designing HyperC from scratch instead, you might choose to ditch the notion of undefined behaviour, which primarily has value for optimisation at the cost of potential bugs.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  13. #58
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148
    Do you understand what "undefined behaviour" means in C?
    I do not. I'm self taught and still learning.
    Last edited by Structure; 09-15-2019 at 02:14 PM.


  14. #59
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,271
    Quote Originally Posted by Structure View Post
    I do not.
    The Wikipedia article is a good starting point: undefined behaviour

    It's essential knowledge for a C programmer because it is such a source of bugs, and even more so if you're designing a language that builds on C, or if you're writing a compiler that uses C as its intermediate language.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #60
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    148
    It is the responsibility of the programmer to write code that never invokes undefined behavior.
    This is how i see it.

    Are you saying i should try not to allow undefined behaviour?
    Last edited by Structure; 09-15-2019 at 02:21 PM.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HyperC Pre Process File Injection
    By Structure in forum Tech Board
    Replies: 2
    Last Post: 08-06-2019, 06:13 AM
  2. The future of the C language is HyperC
    By Structure in forum Projects and Job Recruitment
    Replies: 6
    Last Post: 05-14-2019, 08:55 AM

Tags for this Thread