3 Replies - 1646 Views - Last Post: 04 April 2013 - 09:31 AM Rate Topic: -----

#1 c3phalex1n  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-January 13

metasprograming in ruby

Posted 01 April 2013 - 09:26 AM

Hi guys,
I have a question about programing with the ruby language.
Recently i am begin to learn ruby language which i deal to Metaprograming in frsit of my step...!
My question is : What's metasprograming in ruby?!!
who can help me?!!

Sorry for bad english speak dears.
cheers.
Is This A Good Question/Topic? 0
  • +

Replies To: metasprograming in ruby

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2144
  • View blog
  • Posts: 3,295
  • Joined: 21-June 11

Re: metasprograming in ruby

Posted 01 April 2013 - 09:49 AM

Quote

which i deal to Metaprograming in frsit of my step


I did not understand that. Could you please rephrase?

Quote

What's metasprograming in ruby?


Meta programming is if you define methods, classes or modules using constructs other than def, class or module.
I would say meta programming is if you define them at runtime, but technically all definitions in Ruby happen at runtime.

This post has been edited by sepp2k: 01 April 2013 - 09:49 AM

Was This Post Helpful? 0
  • +
  • -

#3 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1381
  • View blog
  • Posts: 3,510
  • Joined: 28-November 09

Re: metasprograming in ruby

Posted 01 April 2013 - 03:10 PM

Programming that dynamically writes programming. Don't start with it, you need to learn the nuances of the language before you try and dive into something that deep.
Was This Post Helpful? 0
  • +
  • -

#4 NotarySojac  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 428
  • Joined: 30-September 10

Re: metasprograming in ruby

Posted 04 April 2013 - 09:31 AM

In rails, there's metaprogramming involved where you can say

new_MODEL_NAME_path(@blah)



and when ruby realizes that no one wrote a method named new_MODEL_NAME_path, it reads the method name called and parses out the 'MODEL_NAME' component and then performs action on that model (assuming that model has been defined somewhere).

I think meta-programming is a cool aspect of ruby. I occasionally browse the .NET forum section and sometimes when people ask about "how do you dynamically..." they get yelled at for asking about making viruses and hacking peoples computers and their threads get locked, lol. So yeah, not all languages have this kind of 'quirk' to them... although .NET 5 is supposed to have more dynamic programming features, and at that point I think people will learn more about what meta-programming is. At this point not everyone understands what it's useful for. Lemur is right that you shouldn't start with meta-programming before you know how to program with more conventional patterns.

This post has been edited by NotarySojac: 04 April 2013 - 09:32 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1