Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y
non-lame halfbakery tagline

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.

user:
pass:
register,


                             

Please log in.
Before you can vote, you need to register. Please log in or create an account.

"Concerning" statement for programming languages

Opposite of the "With" statement.
  (+4)
(+4)
  [vote for,
against]

Many object-oriented programming languages offer a "With" structure, which lets you quickly alter several properties of the same object. For example:

With MyPage.MyForm.TextBox1.Font
.bold = true
.italic = true
.size = 16
End With

But often you'd like to change the same named property of several *different* objects, and so far I haven't seen a language with a statement that allows this. Here's what I'd like:

Concerning Font.bold
MyPage.MyForm.Textbox1. = True
MyPage.MyForm.Label1. = False
MyOtherPage.MyOtherForm.CommandButton1. = True
End Concerning

This would not speed up processing time, but it would make the syntax easier to read (for humans), and faster and less error-prone to type.

phundug, Feb 20 2009

[link]






       pardon my mixing metaparticles but "bold" is an attribute, not an object: if you want to do what you want to do you have to associate it with an object and transfer the object's properties, ie: if it seems that important then start looking for an heretofore intangible object you may have missed somewhere along the line.
FlyingToaster, Feb 20 2009
  

       I think the more logical way to construct this is as a 'ubiquitous method' to any object within the current scope:   

       function ubiquitous boldit(state)
{
try {this.Font.bold = state;}
catch {return false;}
}

MyPage.MyForm. Textbox1.boldit(true);
MyPage.MyForm. Label1.boldit(false);
MyOtherPage.MyOtherForm. CommandButton1. boldit(true);
  

       boldit.destroy();
vincevincevince, Feb 20 2009
  

       [bs] you can do it in quite a few programming languages: I'm thinking a multiple "SET" type statement, but OO/C# no clue.
FlyingToaster, Feb 20 2009
  

       Or how about an intelligent "Bolding" agent to whom you can supply a list of object identifiers, and who's task is to spawn itself a new thread for each id which a child process will then use to go off and interrogate the identified object's classification for clues asserting its "boldability" (or any other pseudo-interfacial attribute you care to assign to this agent - which could be everything?!) on determining suitability, it will communicate with said object (using some predetermined protocol) instructing those objects to enbolden themselves appropriately.   

       The benefits of using this method is that you can distribute execution across multiple networks if you want - finally, a true process distributed type-setting engine!!! And about time too.
zen_tom, Feb 20 2009
  

       Can I ask a silly question? Yes. May I?   

       Is there a sort of meta-language that lets you write sections of code in the most appropriate programming language, something like:   

       LANG=C++
do this; do that; do something else; this bit written in C
  

       LANG=JAVA
some Java code
  

       LANG=FORTRAN
some cuneiform fortran
  

       etc ?
MaxwellBuchanan, Feb 20 2009
  

       The reason I like the "Concerning Font.bold" statement is that, when reading the program, as soon as you see that, you know right away what that whole section does and whether you care about it or not.
phundug, Feb 20 2009
  

       I know I over-egged it, and others here have suggested the same thing, but I think just having some function (method, class, whatever your preferred language might call it) that "Does Bold" on a set of objects sent to it is the way forward - it's easy to see what it's doing (the actual boldy stuff happens somewhere outside of the main program-flow) and that's it.   

       Sure, you could create some clever in-language way to deal with that kind of thing, but isn't that what functions (methods, classes, etc) are for anyway?
zen_tom, Feb 20 2009
  

       [MB] some language compilers allow for inline code from other languages... obviously you'd need a compatible other-language compiler on hand.
FlyingToaster, Feb 20 2009
  

       In any case, if you are making so many individual changes to the boldaility of items, it is likely that you should be collecting them into some form of group and applying a general transform. However, if the boldality is an expression of logic (e.g. transmitting information other than style) then writing things out in the 'traditional' and non-concerning way would make more sense to me.   

       Then you are just left with the challenge of ensuring that screen-readers relate your boldality as you expect.
vincevincevince, Feb 21 2009
  

       I'm not convinced that the With statement makes code any easier to read. Concerning might do slightly better though. A series of assignments on one object will line up on the screen, while a series of assignments on one property will not line up without odd formatting.
Bad Jim, Feb 21 2009
  

       This is kind of the whole point of lambdas and similar access to functions as first-class objects. The problem you're addressing is an artifact of Java sucking, not a general problem.   

       lists:map( fun (X) -> bold(X) end, [Form1, Form2, Form3])   

       [form1, form2, form3].map { |x| x.bold = true }   

       map { $_->bold } ($form1, $form2, $form3)   

       Just use a language that isn't actively hostile to programmers.
partdavid, Feb 22 2009
  

       I miss macros :(
theircompetitor, Feb 22 2009
  

       //some cuneiform fortran//   

       I've seen something a bit like this home-brewed.   

       As I recall, someone had set up their makefile to run a pre-processor program before calling the compiler, and that pre-processor recognized certain home-made tokens in the source code to mean "*this* part is to be passed as-is to a vanilla C-compiler, but *that* part is to tapped on the shoulder and led off to a quite different and undocumented destination". It was an extraordinary rendition of program logic. It also involved some steganographic bamboozling of compilers in relation to the source code that *was* passed to them. I now forget the details.   

       Something not unlike this also happened in a poorly thought-out API that I once had to work with, whereby fragments (not complete statements) of SQL had to be delivered via bits of home-made syntax embedded in un-XSDed XML documents, manipulated at various stages of the process in C# (or, in earlier versions, VB script). Now, *that* was concerning.
pertinax, Apr 06 2014
  

       Ruby can do this. Put the objects you want to set the property for into an array, and iterate over them with the each method, calling the setter method on each object. This is pretty basic stuff, actually.   

       Basically, Ruby is the best programming language ever, and everyone should use it because of its sheer awesomeness.
ytk, Apr 06 2014
  
      
[annotate]
  


 

back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle