Code Monkey home page Code Monkey logo

Comments (10)

Sod-Almighty avatar Sod-Almighty commented on August 24, 2024 1

Auto-vars might actually be pretty useful.

from onyx-lang.

Sod-Almighty avatar Sod-Almighty commented on August 24, 2024

This explanation is difficult to follow. And even after following it, I don't see the point. The ' suffix is used in mathematics because there is no implied sense of the passage of time:

a = a + 1    -- total nonsense in mathematical terms

a' = a + 1   -- the suffix is needed to indicate a change is occurring, rather than an assertion

In programming, this is not needed:

value = some-calculation
value = value.some-further-processing
puts value

In the case of wrapped functions, as in your second example, I personally suffix an underscore. Ruby example:

def print(hash)
  print_(hash, 0)
end
private def print_(hash, indent_level)
  hash.each do |k,v|
    case v
      when Hash, Array
        puts "%s: " % k
        print_(v, indent_level+1)
      else
        puts "%s: %s" % [k,v]
    end
  end
end

Also, sometimes it's better to make it a nested function, or an anonymous function. Speaking of which, it'd be handy to be able to recurse an anonymous function. We'd need a keyword (a la super) or some kind of lexical reference, that means "the current function":

->(){
  .()     # infinite recursion
}.()

from onyx-lang.

ozra avatar ozra commented on August 24, 2024

In programming, this is not needed

Those derived values are all used subsequently. The imperative mutating example you show doesn't counter that use example. I write zillions of lines of code like that in series analysis, where there are often derived series from others with slight variations that occur again and again, and where tacking on name-suffixes makes little sense or help.

In the case of wrapped functions, as in your second example, I personally suffix an underscore.

That's a valid approach. I don't think it looks better or clearer though.

Further discussion on anon self reference should go into it's own issue.

from onyx-lang.

Sod-Almighty avatar Sod-Almighty commented on August 24, 2024

derived series from others with slight variations that occur again and again

Then I'm afraid I don't really understand the problem we're trying to solve.

from onyx-lang.

ozra avatar ozra commented on August 24, 2024

Exactly what I described in the examples? :-P

from onyx-lang.

ozra avatar ozra commented on August 24, 2024

Yet other examples where "pretty much the same thing" is needed, the very idiomatic "assign to local to lock the state for flow inference":

type Foo
   @foo Int32?  'get 'set
   @bar Str?  'get 'set

   do-some-shit() ->
      if foo' = foo && bar' = bar
         do-stuff-with foo', bar'
         foo'.more-stuff bar'
      end
   end
end

Not necessarily an argument for ' specifically, but for the ability to have a character to de-facto signify such uses.

from onyx-lang.

Sod-Almighty avatar Sod-Almighty commented on August 24, 2024

I still don't understand the problem we're trying to solve here.

from onyx-lang.

ozra avatar ozra commented on August 24, 2024

Get a good way of naming the temp, derivative or main-impl, etc. commonly reoccurring constructs where a new var/func is needed, but it's not really something that reasonably should be named differently.

Like you solve it with foo_. (That is common for initialization lists in C++ also, and sometimes instance vars - different style guides). So simply something that does have such a connotation (which prime has) rather than using, for instance, underscore.
I think it would be a helpful feature for some idiomatic patterns.

from onyx-lang.

ozra avatar ozra commented on August 24, 2024

Btw, the real prime character () isn't supported in any of the popular monofonts (when I tried on google fonts) :-(

from onyx-lang.

ozra avatar ozra commented on August 24, 2024

Well, this will definitely be a go. It's super-useful. And some syntax to do auto-var-naming: if (foo?.stuff?.here?)' and (qwo())' then use(foo-stuff-here', qwo')

from onyx-lang.

Related Issues (20)

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.