Besides macros, are there any other metaprogramming techniques? [duplicate]

Possible Duplicate:
Programming languages with a Lisp-like syntax extension mechanism

I’m making a programming language, and, having spent some time in Lisp/Scheme, I feel that my language should be malleable. Should I use macros, or is there something else I might/should use? Is malleable syntax even a good idea? Is it perhaps too powerful a concept?

In doing some research, I found fexprs. I don’t really understand what these are. Help with that in an answer too please.

Is it possible to have a language with macros/something-of-a-similar-nature without having s-expressions?

3

You might want to take a look at Ruby, which has a great deal of support for metaprogramming. The book Eloquent Ruby covers the language well, with a significant amount of attention to metaprogramming in the later chapters. There is also a book called Metaprogramming Ruby that is well-reviewed, but which I have not personally read yet.

Metaprogramming in Ruby is far more flexible (and powerful . . . and dangerous) than what is provided by .NET’s Reflection libraries (since Guy Coder mentioned C# in his answer, I thought this comparison might be useful). In Ruby, you can use hooks to dynamically select which mixin modules you want to add to a class at runtime, use “method_missing” for flexible error handling and delegation, use monkey patching to choose what code to add in dynamically, and get yourself into all kinds of awesomely amazing trouble writing self-modifying code. This makes Ruby a very powerful language for, e.g., writing your own domain-specific language (DSL).

Note: I used a lot of jargon in the second paragraph. My hope is that this will provide people who are interested in more information with search terms for web searches, in case someone wants to know more but isn’t ready to buy a book on the topic yet.

2

As I don’t know exactly what you mean by malleable, for the purpose of this question I will take it to mean a language that can be extended.

While I do understand the concept of LISP macros, and how it extends the language, the language that I most associate with this ability is PROLOG.

PROLOG has the ability to define new clauses and add them to its knowledge base by using the assert command. Clauses can also be removed by the retract command.

Stepping further away from the PROLOG where the concept is built into the language and into languages where the dynamic runtime code can be modified with Meta programming or reflection, then we find languages such as Java and C#.

In my view if you are designing a new language and what to give it malleability, then start with the way PROLOG does it naturally in the language and build from there. Languages that use other means to achieve malleability in my view are treating it like an afterthought and it shows.

As an example, take a look at Mercury. This is functional/logic language that is malleable and yet is more than just PROLOG.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật