dynamic-languages


How to access locals through stack trace? (Mimicking dynamic scope)

余生长醉 提交于 2020-01-01 05:05:09
问题 Background Even though it's possible to compile C# code at runtime, it's impossible to include and run the generated code in the current scope. Instead all variables have to be passed as explicit parameters. Compared with dynamic programming languages like Python, one could never truly replicate the complete behaviour of eval (as in this example). x = 42 print(eval("x + 1")) # Prints 43 The question So my question is (regardless if it's actually useful ;)) whether it's possible to mimic

Short description of the scoping rules?

独自空忆成欢 提交于 2019-12-31 05:28:25
问题 What exactly are the Python scoping rules? If I have some code: code1 class Foo: code2 def spam..... code3 for code4..: code5 x() Where is x found? Some possible choices include the list below: In the enclosing source file In the class namespace In the function definition In the for loop index variable Inside the for loop Also there is the context during execution, when the function spam is passed somewhere else. And maybe lambda functions pass a bit differently? There must be a simple

In what languages can you dynamically rewrite functions on the fly?

本小妞迷上赌 提交于 2019-12-23 10:47:11
问题 I recently had the necessity of rewriting a javascript function in javascript, dynamically. The ease with which I did it, and how fun it was, astounded me. Over here I've got some HTML: <div id="excelExport1234" onclick="if(somestuff) location.href='http://server/excelExport.aspx?id=56789&something=else'; else alert('not important');" >Click here to export to excel</div> And I couldn't change the outputted HTML, but I needed to add an extra parameter to that link. I started thinking about it,

Is DB connection pooling all that important?

别说谁变了你拦得住时间么 提交于 2019-12-21 22:04:24
问题 In the Java world it is pretty standard for app servers to pool "expensive" resources, like DB connections. On the other hand in dynamic languages, most stacks have little to do with pooled resources and especially DB connections. E.g. for the popular PHP+MySQL combo, I've rarely seen it used with persistent connection, which can be considered poor-mans pooled connections. If the concept of pooling DB connections is not that widely implemented, does this mean that the performance/scalability

How do you program differently in dynamic languages?

老子叫甜甜 提交于 2019-12-20 09:11:08
问题 How would someone who really knows how to take advantage of dynamic programming languages approach programming differently than someone working in a static language? I'm familiar with the whole debate over static versus dynamic typing, but that's not what I'm getting at. I'd like to discuss problem solving techniques that are practical in dynamic languages but not in static languages. Most of the code I've seen written in dynamic programming languages isn't very different than code written in

Uses for Dynamic Languages

喜欢而已 提交于 2019-12-18 15:54:15
问题 My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. The bottom line is that, if I'm going to learn Python, I want to learn it

Can Perl be “statically” parsed?

别等时光非礼了梦想. 提交于 2019-12-18 12:28:38
问题 An article called "Perl cannot be parsed, a formal proof" is doing the rounds. So, does Perl decide the meaning of its parsed code at "run-time" or "compile-time"? In some discussions I've read, I get the impression the arguments stem from imprecise terminology, so please try to define your technical terms in your answer. I have deliberately not defined "run-time", "statically" or "parsed" so that I can get perspectives from people who perhaps define those terms differently to me. Edit: This

How to create inline objects with properties in Python?

試著忘記壹切 提交于 2019-12-18 10:58:23
问题 In Javascript it would be: var newObject = { 'propertyName' : 'propertyValue' }; How to do it in Python? 回答1: obj = type('obj', (object,), {'propertyName' : 'propertyValue'}) there are two kinds of type function uses. 回答2: Peter's answer obj = lambda: None obj.propertyName = 'propertyValue' 回答3: Python 3.3 added the SimpleNamespace class for that exact purpose: >>> from types import SimpleNamespace >>> obj = SimpleNamespace(propertyName='propertyValue') >>> obj namespace(propertyName=

What makes Ruby slow? [closed]

送分小仙女□ 提交于 2019-12-18 10:07:26
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . Ruby is slow at certain things. But what parts of it are the most problematic? How much does the garbage collector affect performance? I know I've had times when running the garbage collector alone took several seconds, especially when working with OpenGL libraries. I've used

Dynamic languages - which one should I choose?

情到浓时终转凉″ 提交于 2019-12-13 13:26:17
问题 Dynamic languages are on the rise and there are plenty of them: e.g. Ruby, Groovy, Jython, Scala (static, but has the look and feel of a dynamic language) etc etc. My background is in Java SE and EE programming and I want to extend my knowledge into one of these dynamic languages to be better prepared for the future. But which dynamic language should I focus on learning and why? Which of these will be the preferred language in the near future? 回答1: Learning Ruby or Python (and Scala to a

工具导航Map