Giter Club home page Giter Club logo

stack's People

Contributors

dontbelieveme avatar noah11012 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stack's Issues

Refactoring of Code Base

Now that the error refactoring is complete, I think refactoring other parts of the code base should be done as well. Rename functions that are confusing to understand, refactoring the parser, and cleaning up the code in general. Adding better documentation is in order also.

I have one question about the Macro struct in parse.h. What does it do?

Inconsistent Error Reporting Mechanism

Currently error reporting is abysmal and needs some serious refactoring. Certain functions can't report an error if something went awry because: a) the return value is void or b) the function does return a value but you can't return error codes because it would limit the abilities of particular operations.

Take stack_pop() for example. It pops the top item off the stack and returns it. If you pop from an empty stack that is called a stack underflow. If the function returns any number like -1 to signify a stack underflow, then arithmetic operations with that designated error number is impossible.

Another example is stack_dup(). Its implementation pops off a value then pushes it twice back onto the stack. What if the stack is empty? Like said before, popping from an empty stack yields a stack underflow. How do we let the calling user of stack_dup() know that an error happened? We can't currently because of how the function is setup.

My proposal for the solution is to allow all functions that return a pointer return 0 on failure and every other function have an additional output parameter for the error code. Another one is all functions return a status code and the return value is an output parameter.

For example:

stack *stack_new()

becomes

error_code_t stack_new(stack **new_stack);

I wanted to run this by you before doing the refactoring to see what you think.

Implement a proper parser

When I began this project I had no idea about parsers or anything. Now I return, armed with the knowledge of several crudely implemented simple parsers. Aha!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.